GridDropDownColumn

2 posts, 0 answers
  1. Kim
    Kim avatar
    47 posts
    Member since:
    Jul 2013

    Posted 27 Oct 2013 Link to this post

    Hi, I am having trouble implementing a simple GridDropDownColumn

    <telerik:GridDropDownColumn UniqueName="OrderStatusID" DataField="OrderStatus" ListValueField="Description" ListTextField="ID" Headertext="Order Status" ></telerik:GridDropDownColumn>

    First, OrderStatus is not showing in the grid, second, how to I populate the drop down list in code behind? The list contains a list of Items with properties ID and Description


    Thanks.





  2. Angel Petrov
    Admin
    Angel Petrov avatar
    1145 posts

    Posted 30 Oct 2013 Link to this post

    Hello Kim,

    In order to display the OrderStatus in scenarios where a DataSourceID is not defined you should set it as a ListDataMember:

    ASPX:
    <telerik:GridDropDownColumn UniqueName="OrderStatusID" DataField="OrderStatus" ListDataMember="OrderStatus" ListValueField="Description" ListTextField="ID" Headertext="Order Status" ></telerik:GridDropDownColumn>

    As for dynamically populating the drop down this is achievable by following the below listed steps:
    1. Subscribe to the OnItemDataBound event of the grid.
    2. Obtain a reference to RadComboBox in the edit item.
    3. Assign a data source to it and call .DataBind.

    For obtaining a reference to the drop down you can use this code:

    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
       {
           GridEditableItem editItem = e.Item as GridEditableItem;
           if (editItem != null && editItem.IsInEditMode)
           {
               RadComboBox editItemCombo = editItem["OrderStatusID"].Controls[0] as RadComboBox;
               //Implement data binding logic
           }
       }

    Regards,
    Angel Petrov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top