Simple editing problem

5 posts, 0 answers
  1. Ben
    Ben avatar
    23 posts
    Member since:
    Mar 2012

    Posted 18 Jun 2012 Link to this post

    I am new to Telerik controls having recently migrated from Xceed.


    I’m attempting some simple editing of a dataset using the RadGridView control. 


    I bind the ItemSource of the RadGridView through code.  When I click on an auto generated column, the data editing works perfectly.  When I try to edit a column that I have defined  as a GridViewDataColumn, I get an empty text box (the bound data disappears) and my changes to do not commit when I leave the column.

    telerik:RadGridView Name="gvInelig" telerik:StyleManager.Theme="Office_Black">


        <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding EmpNameFullLF}"/>




    Take the grid above for example.  I have defined one column called "Name" which is bound to a column in the dataset called "EmpNameFullLF".  I can see my defined "Name" column along with the auto generated "EmpNameFullLF" column in my grid. 

    When I click to edit the "Name" column, the bound data disappears and I get an empty text box.  If I type and hit enter, my change does not commit. 
    When i click into the auto generated "EmpNameFullLF" column, I can change the bound data and my change persists when the row leaves edit mode.

    Obviously, I’m missing something.  It's probably something simple.   However, I’ve looked through the demos and I don’t see what it is.  Any help is greatly appreciated.  Thank you.

  2. Ben
    Ben avatar
    23 posts
    Member since:
    Mar 2012

    Posted 18 Jun 2012 Link to this post

    While testing I discovered something.  This probably won't come as news to someone who has used the RadGridView control a lot.  Since this is the first time I have used it, it was a surprise to me.

    When I bind the RadGridView to a data table from a SQL data call (stored proc or simple select statement), my GridViewDataColumns behave in the way I describe in my first post.  They don't work correctly in edit mode.

    As a test, I created a simple Employee class and bound my RadGridView to a collection of the class, similare to a tutorial in the Telerik documentation.  I found when I bind my grid to the collection of classes, my GridViewDataColumns work perfectly in edit mode.

    Why would the RadGridView control react differently to these different data sources?  What do I need to do to get GridViewDataColumns to perform edits against a SQL data source?

    Thank you.
  3. DevCraft R3 2016 release webinar banner
  4. Vlad
    Vlad avatar
    11100 posts

    Posted 19 Jun 2012 Link to this post


     When binding to DataTable (DataRow will use indexes instead properties) you should use square brackets for your bindings. For example:

    <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding [EmpNameFullLF]}"/>

    To avoid further confusion you can use the table DefaultView instead for RadGridView ItemsSource. 

    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Darshan
    Darshan avatar
    2 posts
    Member since:
    Jun 2015

    Posted 29 Mar Link to this post

    Hello Vlad,

    I am facing similar issue. Here in my case, I have set AutoGenerateColumns="True" on radgridview. When I try to edit value from a cell, the bound data disappears and I get an empty text box. If I type and hit enter, my change does not commit.

  6. Stefan X1
    Stefan X1 avatar
    482 posts

    Posted 30 Mar Link to this post

    Hello Darshan,

    Such behavior of RadGridView is not reproducible at my side. I am attaching the sample application I used for testing. Can you please check it out?

    If it does not help, would it be possible for you to modify it as per your project setup and send it as attachment in a new support thread?

    Stefan X1
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top
DevCraft R3 2016 release webinar banner