我尝试更改gridview行中的dropdownlist.enabled。
我写了这个代码块。
if (isEdit && index == e.Row.RowIndex)
{
foreach (GridViewRow item in GridView1.Rows)
{
if (item.RowIndex == index)
{
DataRowView rowView2 = (DataRowView)item.DataItem;
DDL = (DropDownList)item.FindControl("ddlLocation");
DDL.Enabled = true;
isEdit = false;
}
}
}
从GridView1_RowEditing获取isEdit
喜欢:
isEdit = true;
从row命令获取索引 喜欢:
if (e.CommandName == "Edit")
{
index = Convert.ToInt32(e.CommandArgument);
}
有人可以帮助我吗?
答案 0 :(得分:1)
您应该能够将代码简化为:
if (isEdit)
{
DropDownList DDL = (DropDownList)GridView1.Rows[index].FindControl("ddlLocation");
DDL.Enabled = true;
isEdit = false;
}