更新时间:2023-10-07 09:47:52
试试这个。
protected void gvEmp_RowEditing(object sender, GridViewEditEventArgs e)
{
DemoGrid.EditIndex = e.NewEditIndex;
BindGrid();
DropDownList dropdown = gvEmp.Rows[e.NewEditIndex].FindControl("DropDownList1") as DropDownList;
BindDropDown(dropdown);
}
private void BindDropDown(DropDownList temp)
{
string connectionString = "Password=priyal;User ID=priyal;Initial Catalog=asptest;Data Source=dbsvr";
string query = "select deptno from employees";
DataSet dataset = new DataSet("Employees");
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlDataAdapter adapter = new SqlDataAdapter(query, connection))
{
adapter.Fill(dataset);
}
}
temp.DataSource = dataset;
temp.DataTextField = "deptno";
temp.DataValueField = "deptno";
temp.DataBind();
}
除非你通过行的DropDownList
作为参数,如何将你的 BindDropDown
识别哪些 DropDownList的
绑定到?
Unless you pass the rows DropDownList
as a parameter, how would your BindDropDown
recognize which DropDownList
to bind to?