【发布时间】:2011-04-28 13:32:00
【问题描述】:
我将 DropDownList 插入到 GridView 内的 EditItemTemplate 中,并且我想使用基于同一行上另一个 GridView-Column 中的值的项目来填充此 DropDownList。
让我举个例子:
如果该行如下所示:
项目名称、字符串、文本框、(编辑按钮)
我希望单击 EditButton 将字符串“TextBox”转换为带有选项“TextBox”或“DropDownList”的 DropDownList,但如果该行看起来像这样:
项目名称、布尔值、复选框、(编辑按钮)
我希望 DropDown 仅包含“CheckBox”和“RadioButton”。
因此,从逻辑上讲,我需要访问 a) 包含数据类型字段(字符串或布尔值)值的列和 b) 访问 DropDown-List 以修改其在 GridView_RowEditing-Event 中的项目。
我已经完成了 a),谁能帮我解决 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();
}
谢谢,
丹尼斯
【问题讨论】:
标签: c# gridview drop-down-menu edititemtemplate