这是我的代码
con.Open();
ImageButton btndetails = sender as ImageButton;
GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer;
BindRolesdropdown();
ddl.SelectedValue = gvrow.Cells[1].Text;
protected void BindRolesdropdown()
{
SqlCommand cmd = new SqlCommand(" select distinct Rolename,RoleId from Roles", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
ddl.DataTextField = "Rolename";
ddl.DataValueField = "RoleId";
ddl.DataSource = ds;
ddl.DataBind();
ddl.Items.Insert(0, new ListItem("--Select--", "0"));
}
我的0 th 单元格是图像编辑按钮。当我点击弹出窗口时会显示。但现在值没有绑定在下拉列表中,即gridview。
我的sql表Roles
RoleName RoleId IsActive
Admin 324F5D29-4A8F-43F3-B060-1589F6BDBFC8 1
Team Leader 944C2E84-A648-4293-9D5A-EA58FB9727B6 1
如果我在网格中选择Admin行,则网格内的弹出窗口应显示admin下拉列表。我怎样才能做到这一点?