【发布时间】:2010-06-16 19:15:26
【问题描述】:
我有一个单击“添加新记录”按钮的网格,显示带有角色的文本框:[TextBox] 以及它下方的复选框和取消按钮。该网格只有一个名为 RoleName 的列,其标题为 Role,如下所示。
(来源:rjmueller.net)
当我单击复选框按钮时,我正在触发使用具有三个参数(applicationId、applicationName、rolename)的 objectdatasource 的 InsertCommand。 roleName 需要是文本框的值。
我的网格叫做 gvRoles。
我的对象数据源称为 dsSecurity。
我可以使用几行代码来获取这个值吗?
protected void gvRoles_InsertCommand(object source, GridCommandEventArgs e)
{
//I need code here to retrieve the value of the textbox
dsSecurity.InsertMethod = "InsertRole";
String applicationId = cmbApplications.SelectedValue;
String applicationName = cmbApplications.SelectedItem.Text;
String roleName = "I need to set the role name from the textbox";
dsSecurity.InsertParameters["applicationId"].DefaultValue = applicationId;
dsSecurity.InsertParameters["applicationName"].DefaultValue = applicationName;
dsSecurity.InsertParameters["roleName"].DefaultValue = roleName;
gvRoles.DataBind();
}
【问题讨论】: