Fill datasource in RadComboBox within EditItemTemplate of RadGrid

6 posts, 1 answers
  1. Computer Surgeon
    Computer Surgeon avatar
    41 posts
    Member since:
    Nov 2008

    Posted 21 Dec 2008 Link to this post

              I need to populate text , value pair in RadComboBox. Please help me out to get ride of filling datasource in radcombobox which is placed within radgirid Edit Item Template. Without using DataSourceID="SqlDataSource1" . And binding radcombobox using codebehind on RadGrid Item databound.

            While i click on "ADD NEW RECORD " the RadComboBox within the EditItemTemplate sholud get populated.


    telerik:GridTemplateColumn HeaderText="Document Type" HeaderButtonType="TextButton">






    <asp:Label runat="server" ID="lblDocType" Text='<%# Eval("DocumentType") %>' />









    <telerik:RadComboBox ID="RCBAccDocType" runat="server" Width="130px" Skin="Office2007">









    <ItemStyle Width="12%" HorizontalAlign="Left" />



    <HeaderStyle Width="12%" HorizontalAlign="Center" />




    Happy coding ;-)


  2. Answer
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Dec 2008 Link to this post


    Try the following code snippet to fill the DropDownList in Insert mode.

     <telerik:GridTemplateColumn HeaderText="TempCol" UniqueName="TempCol" > 
                       <asp:DropDownList ID="RCBAccDocType" runat="server"

     protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
            if ((e.Item is GridEditFormInsertItem) && (e.Item.OwnerTableView.IsItemInserted)) 
                GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item; 
                DropDownList combo = (DropDownList)insertItem["TempCol"].FindControl("RCBAccDocType"); 
                SqlConnection conn = new SqlConnection(connectionstring); 
                SqlDataAdapter adp = new SqlDataAdapter("select ProductName,ProductID from  Products ", conn); 
                DataTable dt = new DataTable(); 
                combo.DataSource = dt; 
                combo.DataTextField = "ProductName"
                combo.DataValueField = "ProductID"

  3. Computer Surgeon
    Computer Surgeon avatar
    41 posts
    Member since:
    Nov 2008

    Posted 22 Dec 2008 Link to this post

    Thanks for your guidance.
  4. Atit Thaker
    Atit Thaker avatar
    2 posts
    Member since:
    Oct 2009

    Posted 15 Oct 2009 Link to this post

    Thanx for you help buddy. :)

    I am attaching your code in :

    If (TypeOf e.Item Is GridEditFormInsertItem) AndAlso (e.Item.OwnerTableView.IsItemInserted) Then
                Dim insertItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem)
                Dim combo As DropDownList = DirectCast(insertItem("Roles").FindControl("RCBAccDocType"), DropDownList)
                combo.DataSource = dsh.PersonnelRole
                combo.DataTextField = "RoleName"
                combo.DataValueField = "PersonnelRoleID"
            End If
  5. Maulin
    Maulin avatar
    3 posts
    Member since:
    Mar 2016

    Posted 12 May 2016 in reply to Shinu Link to this post

    Is there a way to do same thing on clientside ?
  6. Kostadin
    Kostadin avatar
    1733 posts

    Posted 17 May 2016 Link to this post

    Hi Maulin,

    I am afraid you cannot bind the RadComboBox on the client since grid requires the selected value to be send to the server. Nevertheless, a possible solution is to use load on demand feature of the ComboBox control to populate it. Please check out the following live example which demonstrates that.

    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top