This is a migrated thread and some comments may be shown as answers.

Add new record defaults

1 Answer 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 02 Jul 2012, 09:45 AM
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

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 04 Jul 2012, 01:50 PM
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.
Tags
General Discussions
Asked by
Paul
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or