请ASP.net高手帮帮忙(急!谢谢了..在线等..)

来源:百度知道 编辑:UC知道 时间:2024/07/05 05:07:55
我有一张表(sql server)
里面字段有:
kindid(int) typeid(int) kindname(ntext)
kindid是主键,typeid存的是类型分组,kindname是类别名称
我想让DropDownList显示出数据来
DropDownList1显示typeid为1的kindname;
DropDownList2显示typeid为2的kingname;
怎么实现啊?
我是这样绑定的:
DataSet ds = plankind.getDataSet();;
this.DropDownList1.DataSource = ds.Tables[0].DefaultView;
this.DropDownList1.DataTextField = "kind_name";
this.DropDownList1.DataValueField = "type_id";
this.DropDownList1.DataBind();
this.DropDownList1.Items.Insert(0, new ListItem("--请选择--", "0"));

this.DropDownList2.DataSource = ds.Tables[0].DefaultView;
this.DropDownList2.DataTextField = "kind_name";
this.DropDownList2.DataValueField = "type_id";
this.DropDownList2.DataBind();
this.DropDownList2.Items.I

DataSet ds = plankind.getDataSet();
DataTable dt = null;
dt1 = ds.Tables[0].Clone;
DataRow[] dat1 = ds.Tables[0].Select("type_id='1'");
foreach (DataRow dr in dat1)
{
dt1.ImportRow((DataRow)dr);
}

dt2 = ds.Tables[0].Clone;
DataRow[] dat2 = ds.Tables[0].Select("type_id='2'");
foreach (DataRow dr in dat2)
{
dt2.ImportRow((DataRow)dr);
}

this.DropDownList1.DataSource = dt1;
this.DropDownList1.DataTextField = "kind_name";
this.DropDownList1.DataValueField = "type_id";
this.DropDownList1.DataBind();
this.DropDownList1.Items.Insert(0, new ListItem("--请选择--", "0"));

this.DropDownList2.DataSource = dt2;
this.DropDownList2.DataTextField