views:

29

answers:

1

I have a grid that has the "Add new record" button clicked showing the textbox with Role: [TextBox] and the checkbox and cancel buttons below it. The grid has only one columncalled RoleName with a title of Role as shown below.

alt text

When I click the checkbox button, I am firing the InsertCommand that uses an objectdatasource with three parameters (applicationId, applicationName, rolename). roleName needs to be the value of the textbox.

My grid is called gvRoles.

My objectdatasource is called dsSecurity.

Is there just a couple of lines of code that I can use to get this value?

        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();   
    }  
+1  A: 

If you have auto-generated Telerik grid edit form, I would use this code to get what you want:

String roleName = ((e.Item as GridEditableItem)["Role"].Controls[0] as TextBox).Text;

In case you use custom edit form, get reference to the textbox directly calling e.Item.FindControl(id).

Dick

Dick Lampard
As usual, Stackoverflow comes through for me again. Grat answer, Dick, thanks for the help, it worked exactly as I wanted.
RJ