循环显示出下拉框控件
来源:互联网 发布:魔影工厂软件下载 编辑:程序博客网 时间:2024/05/17 14:16
要实现的效果如下图:
下拉框控件的数目是不固定的,是根据某个ID从数据库中读取的,然后要显示在页面上面,并且数据要绑定上去。主要卡住的地方是,如何将控件循环出来,以及将用户选择的内容保存到数据库里面。
<asp:Repeater ID="rep" runat="server">
<ItemTemplate>
<span class="white1">
<%# Eval("Name") %></span><br />
<table width="270" border="0">
<tr>
<td width="169">
<%#BlindsOptions(Eval("ID"))%>
</td>
<td width="91">
<img src="../Images/wh.gif" width="14" height="14" alt ="" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
后台
#region 绑定Repeater控件
/// <summary>
/// 绑定Repeater控件
/// </summary>
/// <param name="whereStr"></param>
protected void BindRep(string whereStr)
{
whereStr = " ID IN(" + ViewState["BlindsOptionsIds"].ToString() + ")";
T_BlindsOptionsBLL obj = new T_BlindsOptionsBLL();
DataSet ds = obj.GetList(whereStr);
rep.DataSource = ds;
rep.DataBind();
}
#endregion
#region 循环显示DropDownList控件,并绑定相应的数据
protected string BlindsOptions(object ID)
{
string returnStr = "";
T_BlindsOptionsItemBLL itemBll = new T_BlindsOptionsItemBLL();
DataSet ds = itemBll.GetList("OptionID=" + Convert.ToInt32(ID));
int count = ds.Tables[0].Rows.Count;
returnStr += "<select name='select_" + ID.ToString() + "' id='select_" + ID.ToString() + "'>";
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
returnStr += "<option value='" + ds.Tables[0].Rows[i]["ID"] + "' >" + ds.Tables[0].Rows[i]["Name"] + "</option>";
}
}
returnStr += "</select>";
return returnStr;
}
#endregion
得到下拉框控件的内容,该方法GetBlindsOptions()得到的数据,保存到数据表中的某个字段里面。
protected string GetBlindsOptions(object objID)
{
string strItem="";
if (objID != null)
{
T_CurtainsInfoBLL bll = new T_CurtainsInfoBLL();
T_CurtainsInfo model = bll.GetModel(Convert.ToInt32(objID));
string[] boID=model.BlindsOptionsIds.Split(',');
for (int i = 0; i < boID.Length; i++)
{
strItem += Request["select_" + boID[i] + ""] + ",";
}
}
string returnStr = strItem.Substring(0, strItem.Length - 1);
return returnStr;
}
- 循环显示出下拉框控件
- html 点击控件显示下拉框
- html下拉框,显示隐藏其他控件
- CComboBox控件的下拉列表框,用鼠标在该ListBox上滑动的时候显示出当前具有focus的item项的索引
- CComboBox控件的下拉列表框,用鼠标在该ListBox上滑动的时候显示出当前具有focus的item项的索引
- Spinner控件显示下拉列表
- UltraCombo,UltraComboEdit 等下拉框控件不显示Header
- 用mfc实现组合框控件下拉列表显示
- UltraCombo,UltraComboEdit 等下拉框控件不显示Header
- JavaScript--在页面的下拉框控件中遍历出日期--能力工场
- jsp中弹出窗口显示下拉框,将下拉框的值传入到另外一个页面
- progStudio Combox 不能显示出 下拉框的效果 的原因
- 点击CComboBox控件的下拉按钮控制下拉框ListBox的显示和隐藏
- 日期控件如何显示出时分秒
- 一个下拉显示时间的控件
- 判断是否显示下拉控件的
- 下拉框控件
- 下拉框筛选控件
- 【原创汉化】Eusing Maze Lock
- mysql大表更新sql的优化策略
- ZOJ-1763
- xxx
- 读《黑客与画家》有感
- 循环显示出下拉框控件
- 数据库设计的黄金经验
- 山东理工大学ACM平台题答案关于C语言 2251 期末考试之分等级
- Windows7(64位)安装Oracle10g
- MySQL常用命令总结
- oracle字符集
- checkbox编辑选中
- 二进制数、位和字节
- 区间分区