我在GridView中的一个EditItemTemplate中插入了一个DropDownList,并且希望在同一行上的另一个GridView-Column中使用基于Value的项填充此DropDownList。GridView_RowEditing中的GridView中的EditItemTemplate中的DropDownList
让我给你举个例子:
如果行看起来是这样的:
ITEMNAME,字符串,文本框,(editbutton)
我要上EditButton点击转换为字符串“文本框”与选项一个DropDownList “文本框” 或 “DropDownList的”,但如果该行看起来是这样的:
ITEMNAME,布尔,复选框(editbutton)
我希望DropDown只具有“CheckBox”和“RadioButton”功能。因此,在逻辑上,我需要访问a)包含数据类型字段(字符串或布尔值)的值的列和b)访问DropDown列表以修改其在GridView_RowEditing-Event中的项目。
我已经管理做了),任何人都可以帮我b)?
我的代码目前看起来是这样的:
protected void gridVariables_RowEditing(object sender, GridViewEditEventArgs e)
{
switch (gridVariables.Rows[e.NewEditIndex].Cells[2].Text)
{
case "string":
case "double":
case "long":
break;
case "bool":
break;
default:
break;
}
gridVariables.EditIndex = e.NewEditIndex;
gridVariables_DataBind();
}
感谢,
丹尼斯
优秀!这种方法也解决了我遇到的另一个问题,非常感谢! – 2011-05-02 09:03:07