Add new record defaults

2 posts, 0 answers
  1. Paul
    Paul avatar
    2 posts
    Member since:
    Jul 2012

    Posted 02 Jul 2012 Link to this post

    Hi - I have a combobox in the template for a new record on the RadGrid. The value selected in this combobox should be taken from a control outside the grid. Where and how can I set the default for the new record control?Thanks,
    Paul
  2. Eyup
    Admin
    Eyup avatar
    3690 posts

    Posted 04 Jul 2012 Link to this post

    Hi Paul,

    You could use the ItemCreated server event of the grid:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditFormInsertItem)
            {
                // find and access the combobox
                GridEditFormInsertItem insertItem = e.Item as GridEditFormInsertItem;
                RadComboBox combo = insertItem.FindControl("YourComboID") as RadComboBox;
     
                // assign the value from the external control
                combo.FindItemIndexByValue(Label1.Text).Selected = true;
            }
        }

    That should do the trick. Please give it a try and let me know about the result.

    Greetings,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top