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

Bind RadDropDownList to RadGrid using DataTable

1 Answer 74 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Yefta asked on 08 Sep 2015, 02:14 AM

Hi, i have a problem. 

I'm using a RadDropDownList in RadGrid when in Edit Mode. But i can't bind the datatable of list to the RadDropDownList.

here's my RadGridCode

<telerik:RadGrid ID="radGridTarget" GridLines="None" runat="server" AllowAutomaticDeletes="True"
    AllowAutomaticInserts="True" PageSize="10" Height="250px" Width="500px"
    OnItemDeleted="radGridTarget_ItemDeleted" OnItemInserted="radGridTarget_ItemInserted"
    OnItemUpdated="radGridTarget_ItemUpdated" AllowAutomaticUpdates="True" AllowPaging="True"
    AutoGenerateColumns="False" onitemdatabound="radGridTarget_ItemDataBound" >
    <MasterTableView CommandItemDisplay="Top" HorizontalAlign="NotSet" EditMode="InPlace" AutoGenerateColumns="False">
        <table width="100%" border="0" cellpadding="20" cellspacing="20">
                <td align="center">
                    <h2 style="color:Black">No Data</h2>
    <PagerStyle Mode="NumericPages"/>
        <BatchEditingSettings EditType="Cell" />
            <telerik:GridBoundColumn DataField="Sales" HeaderText="Sales" Display="false"></telerik:GridBoundColumn>
            <telerik:GridTemplateColumn HeaderText="Target" DefaultInsertValue="Target" HeaderStyle-Width="150px" UniqueName="Target" DataField="Target">
                    <%# Eval("Target") %>
                    <telerik:RadDropDownList runat="server" ID="radDropDownTarget" DataValueField="Value" DataTextField="Target" ></telerik:RadDropDownList>
            <telerik:GridNumericColumn DataField="Amount" HeaderStyle-Width="80px" HeaderText="Target Amount" SortExpression="Amount" UniqueName="Amount">
            <telerik:GridButtonColumn ConfirmText="Delete this target?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" HeaderText="Delete"
                HeaderStyle-Width="50px" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
    <ClientSettings AllowKeyboardNavigation="true"></ClientSettings>

and this is how i bind the RadDropDownList, and not working

protected void radGridTarget_ItemDataBound(object sender, GridItemEventArgs e)
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        GridEditableItem editItem = (GridEditableItem)e.Item;
        RadDropDownList dropDown = (RadDropDownList)editItem.FindControl("radDropDownTarget");
        dropDown.DataSource = _presenter.PopulateTargetList();
        dropDown.DataTextField = "Value";
        dropDown.DataValueField = "Desc";

Please help me. Thank you in advance

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 10 Sep 2015, 08:24 AM
Hi Yefta,

You can use the DataBinding event handler of the dropdown control to achieve this requirement as demonstrated in the attached web site sample. Please give it a try and let me know if it works for you. You can replace the GridDataItem with GridEditableItem within the server-side logic.

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question