后台.cs怎样动态加载select标签的optgroup-CSDN论坛
展开全部
public static void BindDropDownList2(System.Web.UI.HtmlControls.HtmlSelect select, System.Data.DataTable dt, string firstfather_id, string childid, string father_id, string name)
{
System.Data.DataRow[] drs = dt.Select(father_id + "=" + firstfather_id);
for (int i = 0; i < drs.Length; i++)
{
System.Web.UI.HtmlControls.HtmlGenericControl hgc = new System.Web.UI.HtmlControls.HtmlGenericlControl("optgroup");
hgc.Attributes.Add("label",drs[i][name].ToString());
select.Controls.Add(hgc);
}
}
{
System.Data.DataRow[] drs = dt.Select(father_id + "=" + firstfather_id);
for (int i = 0; i < drs.Length; i++)
{
System.Web.UI.HtmlControls.HtmlGenericControl hgc = new System.Web.UI.HtmlControls.HtmlGenericlControl("optgroup");
hgc.Attributes.Add("label",drs[i][name].ToString());
select.Controls.Add(hgc);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询