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

Simple editing problem

4 Answers 147 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 18 Jun 2012, 06:52 PM

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:RadGridView.Columns>

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

  </telerik:RadGridView.Columns>  

</telerik:RadGridView>

 

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.

4 Answers, 1 is accepted

Sort by
0
Ben
Top achievements
Rank 1
answered on 18 Jun 2012, 09:16 PM
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.
0
Vlad
Telerik team
answered on 19 Jun 2012, 06:04 AM
Hi,

 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. 

Greetings,
Vlad
the Telerik team

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

0
Darshan
Top achievements
Rank 1
answered on 29 Mar 2016, 07:44 AM

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.

0
Stefan
Telerik team
answered on 30 Mar 2016, 01:00 PM
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?

Regards,
Stefan X1
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Ben
Top achievements
Rank 1
Answers by
Ben
Top achievements
Rank 1
Vlad
Telerik team
Darshan
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or