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

[Solved] Need Example of Binding a DropDownList in an Edit Template

1 Answer 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 30 Mar 2013, 09:59 AM
I need an example of the following.

  • A RadGrid bound via its OnNeedDataSource event. The grid should also have an Edit Template. 
  • The source of data should include at least two fields, LookupId and LookupValue.  Of these two, only LookupValue should be visible when NOT editing.
  • When editing or inserting, the edit template should contain a DropDownList or RadComboBox bound to a Lookup Table of IDs and Values.  Best would be if that source were an ObjectDataSource since that's what I'm using, but not sure that's required.

This seems like a fairly common scenario, but I'm having no success finding an example. The only example embedded DropDownList in the demo isn't even bound.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Apr 2013, 05:02 AM
Hi,

Try the following code.
C#:
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
   if (e.Item is GridEditableItem && e.Item.IsInEditMode)
   {
            GridEditableItem item = (GridEditableItem)e.Item;
            DropDownList ddl = (DropDownList)item.FindControl("DropDownList1");
            //populate dropdown here
   }
}

Thanks,
Shinu
Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or