Populating a DropDownList in a RadGrid Edit Template

by Al Beecy January 9, 2009
In order to get a reference to a DropDownList (or any other control that needs to be populated or configured) during an edit using a RadGrid edit template, you need to do three things:

1. Declare an event handler for the ItemDataBound event in the ReadGrid tag.

OnItemDataBound="RadGrid1_ItemDataBound"

2. Add the control to your template.

<asp:DropDownList ID="ddl" runat="server"> </asp:DropDownList>

3. Add the event handler to the code-behind.

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode))
    {
        GridEditFormItem editform = (GridEditFormItem)e.Item;
        DropDownList ddl = (DropDownList)editform.FindControl("ddl");
        ddl.Items.Add("foo");
        ddl.Items.Add("bar");
    }
} 

Applies to: RadGrid for ASP.NET AJAX Version Q3 2008

Tags:

Asp.Net | Telerik

Comments

January 23, 2009 #

Web Development Community

Trackback from Web Development Community

Populating a DropDownList in a RadGrid Edit Template

Web Development Community

June 15, 2009 #

DotNetShoutout

Populating a DropDownList in a RadGrid Edit Template

Thank you for submitting this cool story - Trackback from DotNetShoutout

DotNetShoutout

Powered by BlogEngine.NET1.5.0.7 | Theme by Mads Kristensen