dt = db.GetDataSet("select * from model");
DropDownList1.DataSource = dt.Tables[0];
DropDownList1.DataTextField = "content";
DropDownList1.DataValueField = "id";
this. DropDownList1.DataBind();在绑定数据后可以正常显示,但用DropDownList1.SelectedValue和DropDownList1.SelectedItem.Text读取数据时返回的都是第一条记录的值。
请问哪出了问题
DropDownList1.DataSource = dt.Tables[0];
DropDownList1.DataTextField = "content";
DropDownList1.DataValueField = "id";
this. DropDownList1.DataBind();在绑定数据后可以正常显示,但用DropDownList1.SelectedValue和DropDownList1.SelectedItem.Text读取数据时返回的都是第一条记录的值。
请问哪出了问题
{
dt = db.GetDataSet("select * from model");
DropDownList1.DataSource = dt.Tables[0];
DropDownList1.DataTextField = "content";
DropDownList1.DataValueField = "id";
this. DropDownList1.DataBind();
}
可以了,呵呵
这个问题头痛了好长时间
DropDownList1.SelectedValue和DropDownList1.SelectedItem.Text
显示的就是一条数据啊!如果显示多条的话就怪了!