I know there are articles about how to bind GridDropDownColumn with SqlDataSource. However, in my application, I have a data access layer returning a List<> for the GridDropDownColumn. I am wondering how I can use List<> as the source for the GridDropDownColumn in the Edit mode. With the following codes that I have, I have nothing shows up in either browse or edit mode. Thanks,
<telerik:GridDropDownColumn |
DataField="CategoryId" |
HeaderText="Category" |
UniqueName="CategoryId" |
ListTextField="CategoryName" |
ListValueField="CategoryId" /> |
protected void uxApplicationGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
{ |
GridEditableItem editedItem = e.Item as GridEditableItem; |
GridEditManager editMan = editedItem.EditManager; |
GridDropDownColumnEditor editor = editMan.GetColumnEditor("CategoryId") as GridDropDownColumnEditor; |
string selectedValue = editor.SelectedValue; |
editor.DataSource = CategoryDAL.GetCategorys(); // get List<> back from DAL |
editor.DataBind(); |
} |
} |