日期:2014-05-18 浏览次数:20983 次
private void BindProductClassData() { BindProductJgData();BindProductHdData();BindProductBbData(); DataTable dt = SQL.DT("select * from vProductClass order by RootID,Orders"); P_Id.Items.Clear(); DataRow[] drs = dt.Select("ParentId=0"); foreach (DataRow dr in drs) { string classid = dr["classid"].ToString(); string classname = dr["classname"].ToString(); classname = "├─" + classname; P_Id.Items.Add(new ListItem(classname, classid)); int sonparentid = int.Parse(classid); string blank = "│ "; BindDrpNode(sonparentid, dt, blank); } P_Id.DataBind(); } private void BindDrpNode(int parentid, DataTable dt, string blank) { DataRow[] drs = dt.Select("ParentID= " + parentid); foreach (DataRow dr in drs) { string classid = dr["classid"].ToString(); string classname = dr["classname"].ToString(); classname = blank + "├─" + classname; P_Id.Items.Add(new ListItem(classname, classid)); int sonparentid = int.Parse(classid); string blank2 = blank + "├─"; BindDrpNode(sonparentid, dt, blank2); } }
protected string BindDrpNode() { 。。。。 if (reader != null) { while (reader.Read()) { str += "<option value=" + reader["classid"] + ">" + reader["classname"] + "</option>"; } reader.Close(); reader.Dispose(); } return str; } 调用: <select id="Select1" name="Select1"> <%=BindDrpNode()%> </select>