我有一个点击“添加新记录”按钮的网格,显示带有角色的文本框:[TextBox]以及下面的复选框和取消按钮。网格只有一列名为RoleName,标题为Role,如下所示。
alt text http://rjmueller.net/sitesimages/temp/grid.jpg
当我单击复选框按钮时,我将触发使用带有三个参数(applicationId,applicationName,rolename)的objectdatasource的InsertCommand。 roleName必须是文本框的值。
我的网格称为gvRoles。
我的objectdatasource被称为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();
}
答案 0 :(得分:1)
如果您有自动生成的Telerik网格编辑表单,我会使用此代码来获取您想要的内容:
String roleName =((e.Item as GridEditableItem)[“Role”]。Controls [0] as TextBox).Text;
如果您使用自定义编辑表单,请直接调用直接调用e.Item.FindControl(id)的文本框。
迪克