/// <summary> /// /// </summary> /// <param name="d">DropDownList对象</param> /// <param name="nowlayer">当前层</param> /// <param name="so">标识符号</param> /// <param name="sel">选定内容</param> /// <param name="ds">数据集</param> /// <param name="valuename">值字段</param> /// <param name="fidname">当前节点字段名</param> public static void SIMPLEFillDDL(DropDownList d, string sel, DataSet ds, string valuename, string textname) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ListItem li; li = new ListItem(HtmlFilter.OutputFilter(ds.Tables[0].Rows[i][textname].ToString()), ds.Tables[0].Rows[i][valuename].ToString()); if (ds.Tables[0].Rows[i][valuename].ToString() == sel) { li.Selected = true; } d.Items.Add(li); } }
/// <summary> /// /// </summary> /// <param name="d">DropDownList对象</param> /// <param name="nowlayer">当前层</param> /// <param name="so">标识符号</param> /// <param name="sel">选定内容</param> /// <param name="ds">数据集</param> /// <param name="fup">上级节点</param> /// <param name="valuename">值字段</param> /// <param name="textname">标识信息字段名</param> /// <param name="fupname">上级节点字段名</param> /// <param name="fidname">当前节点字段名</param> public static void FillDDL(DropDownList d, int nowlayer, string sel, string so, DataSet ds, string fup, string valuename, string textname, string fupname, string fidname) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i][fupname].ToString() == fup) { ListItem li; //生成前面的标识 string so_layer = ""; for (int j = 0; j < nowlayer; j++) { so_layer = so_layer + so; } li = new ListItem(so_layer + HtmlFilter.OutputFilter(ds.Tables[0].Rows[i][textname].ToString()), ds.Tables[0].Rows[i][valuename].ToString()); if (ds.Tables[0].Rows[i][valuename].ToString() == sel) { li.Selected = true; } d.Items.Add(li); FillDDL(d, (nowlayer + 1), sel, so, ds, ds.Tables[0].Rows[i][fidname].ToString(), valuename, textname, fupname, fidname); } } }