Populate RAD Combo inside Rad Grid

2 posts, 0 answers
  1. Rahul
    Rahul avatar
    14 posts
    Member since:
    Feb 2013

    Posted 09 Jun 2014 Link to this post


    I am new to telerik, I want to design page having a grid which should allow user to insert new row & allow batch update to modify exsisting items, grid should also have combo box columns. I want to poplate grid and all combo box kept in Edit item template on code behind.
    please let me know how to do this.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Jun 2014 in reply to Rahul Link to this post

    Hi Rahul,

    Please try to bind the RadGrid in OnNeedDataSource event and RadComboBox in OnPreRender event as follows.

    <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
        <MasterTableView EditMode="Batch" CommandItemDisplay="Top">
            <BatchEditingSettings EditType="Row" />
                <telerik:GridTemplateColumn DataField="OrderID" UniqueName="OrderID">
                        <telerik:RadComboBox ID="RadComboBox1" runat="server" EmptyMessage="select">

    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        RadGrid1.DataSource = GetDataTable("SELECT [OrderID],[CustomerID] FROM Orders");
    public DataTable GetDataTable(string query)
        String ConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(ConnString);
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = new SqlCommand(query, conn);
        DataTable myDataTable = new DataTable();
        return myDataTable;
    protected void RadGrid1_PreRender(object sender, EventArgs e)
        RadComboBox combo = RadGrid1.FindControl(RadGrid1.MasterTableView.ClientID + "_OrderID").FindControl("RadComboBox1") as RadComboBox;
        combo.DataSource = GetDataTable("SELECT [OrderID] FROM Orders");
        combo.DataTextField = "OrderID";

    Let me know if you have any concern.
  3. DevCraft R3 2016 release webinar banner
Back to Top