How do I access the insert textbox programmatically when you click Add New Record

5 posts, 0 answers
  1. Richard
    Richard avatar
    26 posts
    Member since:
    Oct 2008

    Posted 16 Jun 2010 Link to this post


    I have to set the insert paramaters through the InsertCommand Event of the radgrid and need to get the value of the texbox that shows after you click "Add New Record".  How do I get the value from the textbox?
  2. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 16 Jun 2010 Link to this post

    Hello Richard,

    Please examine the following links:

    [EditForms / InPlace ]
    Inserting values in-place and EditForms

    [UserControl / FormTemplate]
    Inserting values using UserControl/FormTemplate

    Best regards,
    Daniel
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Richard
    Richard avatar
    26 posts
    Member since:
    Oct 2008

    Posted 16 Jun 2010 Link to this post

    Thank you for the links to the examples.  They are helpful but a little over my head with the knowledge I have right now.

    If you view the attached jpg, you will see what I am trying to do.  I have a grid that has the "Add new record" button clicked showing teh textbox with Role: [TextBox] and the checkbox and cancel buttons below it.  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();  
            } 
  5. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 22 Jun 2010 Link to this post

    Hello Richard,

    Depending on your scenario, you could extract the values or get them from the edit controls:
    protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
    {
        GridEditableItem item = e.Item as GridEditableItem;
     
        //Approach 1 - extract the value
        Hashtable table = new Hashtable();
        item.ExtractValues(table);
        var myValue = table["MyDataField"];
     
        //Approach 2 - get the value from the control
        RadTextBox tbox = item.FindControl("MyTextBox") as RadTextBox;
        var myValue2 = tbox.Text; 
    }

    Regards,
    Daniel
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. ejb
    ejb avatar
    6 posts
    Member since:
    Dec 2006

    Posted 26 Jun 2010 Link to this post

    This was awesome thank you
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017