RadGrid Auto Generated Edit Mode Drop Down List Selection Not Binding To Database

2 posts, 0 answers
  1. Katie
    Katie avatar
    1 posts
    Member since:
    Mar 2016

    Posted 22 Dec 2016 Link to this post

    I have an auto-generated radgrid bound to a table.  In Edit Mode, in the code-behind, I have successfully created a drop-down list to replace the default a textbox for ONE column.

    This drop down list pulls its list items from a second table and data source.  The FAILURE POINT is that the selected item from the drop down list is not SAVED to the subject tablet record.  The other columns will update and save properly.  

    The code behind that WORKS for creating the substitute drop-down is here, with my notation as to where I am GUESSING I need to do something correctly.  I have tried every possible forum suggestion, but the source of my pain is that the value in the drop-down list is not being passed to the actual column value on update.  Been stuck for several hours on this one. Probably something silly that I will kick myself for, but not the first time. 

    <p></p>protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
         if (e.Item is GridEditableItem && e.Item.IsInEditMode)
             GridEditableItem edit = (GridEditableItem)e.Item;
             edit["EmployeeRecordID"].Visible = false;
             SqlConnection con = new SqlConnection(MasterConnectionString);
             String queryString = "SELECT GroupLabel From Groups";
             SqlDataAdapter dr = new SqlDataAdapter(queryString, con);
             DataTable dt = new DataTable();
             ddledit = (GridEditableItem)e.Item;
             txt = (TextBox)ddledit["GroupAssociation"].Controls[0];
             //txt.Visible = false;                    
             DropDownList droplist = new DropDownList();            
             droplist.DataSource = dt;
             droplist.DataTextField = "GroupLabel";
             droplist.DataValueField = "GroupLabel";
     protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
         //this is where I THINK my failure point is, but not sure.      
  2. Eyup
    Eyup avatar
    3320 posts

    Posted 27 Dec 2016 Link to this post

    Hi Katie,

    You can access the GridEditableItem instance directly using e.Item argument and depending on your edit mode you can get the values manually:

    In some scenarios, the ExtractValues method can be helpful:

    If you are using templates, make sure that you are using the Bind expression in the form controls in your :

    Alternatively, you can directly try implementing automatic CRUD operations:

    I hope this will prove helpful.

    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top