把无级分类树绑定到下拉列表,以便用户选择,大家都是怎么弄?? 把无级分类树绑定到下拉列表,以便用户选择,大家都是怎么弄?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用递归的思路,绑定到DROPDOWNLIST ,我写过, 不知道代码去哪了 关于地区的表:(广州-中国-亚洲)id,area,parentid districtList为一DROPDOWNLISTprotected System.Data.DataTable dt; private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { SqlConnection cn; cn = new SqlConnection(ConfigurationSettings.AppSettings["cnString"]); SqlCommand cmd1 ; cmd1 = new SqlCommand("select id,area,parentid from district",cn); SqlDataAdapter sda=new SqlDataAdapter(cmd1); DataSet ds=new DataSet(); sda.Fill(ds); dt=ds.Tables[0]; Makelist(0,"0"); cn.Close(); } } private void Makelist(int count,string pid) { String text; int i,j; DataRow[] dr=dt.Select("parentid="+pid); for(i=0;i<dr.Length;++i) { text=""; for(j=0;j<count;++j) text+="-"; text+=dr[i]["area"].ToString(); this.districtList.Items.Add( new ListItem(text,dr[i]["id"].ToString()) ); Makelist(count+1,dr[i]["id"].ToString()); } } 大家能不能帮我看看哪里出了问题?谢谢啦 html单元格设置 asp.net验证控件问题 datagrid中删除对话框如何实现! ASP+Access,向数据库中写入信息出错!请高手指教! Asp.net打开数据库的问题,莫名其妙的,大家来看看 高分求:asp.net页面在不同机器上显示源码不一样,导致validator无效 非常棘手的问题。请各位帮帮忙,小弟先谢了 ie 浏览器的问题 如何向查询分析器那样在网页中显示SELECT的结果集? 进行用户身份验证的方法有哪些啊? (加急)关于Session和Cookie的两个问题
id,area,parentid
districtList为一DROPDOWNLISTprotected System.Data.DataTable dt; private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
SqlConnection cn;
cn = new SqlConnection(ConfigurationSettings.AppSettings["cnString"]);
SqlCommand cmd1 ;
cmd1 = new SqlCommand("select id,area,parentid from district",cn);
SqlDataAdapter sda=new SqlDataAdapter(cmd1);
DataSet ds=new DataSet();
sda.Fill(ds);
dt=ds.Tables[0];
Makelist(0,"0");
cn.Close();
}
} private void Makelist(int count,string pid)
{
String text;
int i,j;
DataRow[] dr=dt.Select("parentid="+pid);
for(i=0;i<dr.Length;++i)
{
text="";
for(j=0;j<count;++j) text+="-";
text+=dr[i]["area"].ToString();
this.districtList.Items.Add( new ListItem(text,dr[i]["id"].ToString()) );
Makelist(count+1,dr[i]["id"].ToString());
}
}