在gridview中绑定的Dropdownlist控件绑定数据问题
-我gridview中,每行都含有一个DropDownList控件,这些控件要绑定一个固定id的数据-例如绑定某部门的所有员工姓名,用DropDownList绑定姓名-请...
-我gridview中,每行都含有一个DropDownList控件,这些控件要绑定一个固定id的数据-例如绑定某部门的所有员工姓名,用DropDownList绑定姓名-请问怎么实现,附上重要代码参考,感谢
展开
1个回答
2013-12-14
展开全部
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
foreach (GridViewRow row in this.GridView1.Rows)
{
DropDownList dr1 = ((DropDownList)row.FindControl("drpClass"));
sql = "select * from Class";
ds = bao.GetDs(sql);
dr1.DataSource = ds;
dr1.DataTextField = "Name";
dr1.DataValueField = "Name";
dr1.DataBind();
}
}
}
{
if (!Page.IsPostBack)
{
foreach (GridViewRow row in this.GridView1.Rows)
{
DropDownList dr1 = ((DropDownList)row.FindControl("drpClass"));
sql = "select * from Class";
ds = bao.GetDs(sql);
dr1.DataSource = ds;
dr1.DataTextField = "Name";
dr1.DataValueField = "Name";
dr1.DataBind();
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询