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

Binding GridDropDownColumn with List<>

1 Answer 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peichung
Top achievements
Rank 1
Peichung asked on 08 Dec 2008, 07:34 PM
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();  
        }  
    } 

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 11 Dec 2008, 11:13 AM
Hi Peichung,

Attached to this message, is a small application, which handles a functionality close to the one that you mentioned. I hope it helps.

Greetings,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Peichung
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or