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

modify cells data of a bounded gridview programmatically

1 Answer 107 Views
GridView
This is a migrated thread and some comments may be shown as answers.
CQT
Top achievements
Rank 1
CQT asked on 08 Jan 2013, 05:22 PM
Hello!
I'm writing an application with a radgridview bounded to a Linq EntityFramework query object and I have a problem in modifying cells content programmatically.

Once my grid is shown with bounded values I want to modify these values direclty in the gridview in editing mode, and this task works fine. Now I want to add a row to the grid with values taken from a function in the code behind. I have a series of value and I want to add them in a new row and show it in my gridview. Since I don't want to put them in database I can't save changes to my entity frameworks query object and then rebind to the gridview, but I simply want to add a row to the grid with my values, until the user want to definitely apply changes.

I tried making a dataset from my linq to entity query (same records as written in the gridview), and then Added new row to the dataset and binding it to the gridview. The last problem is to save changes in database, I should take values from the gridview back to a linq entity query and save changes. After creating a dataset from linq object I should now create a list (linq) from dataset...

To do this I set a new linq to entity query taking records from my dataset, but at this point my application rises error and I can not retrive data to save.

Does anybody faced a similar problem and can give me an example on how to procede? Any example? I search everywhere without finding a solution. In my application I don't use MVVM...

If necessary I can post my faulty code

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 09 Jan 2013, 08:27 AM
Hi,

Just an idea.

You can create an intermediate in-memory ObservableCollection, fill it up with the entities coming from EF and then bind the grid to this middle-tier ObservableCollection. Then add your new row and it will be added to this in-memory collection but not tot he DB. Once you decide you want to save it to the database, you can do it in any way that you want.

Please, note that this question is not directly related to Telerik controls, i.e. if you were using any other ItemsControl to show the data you would have the same question.

Regards,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
CQT
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or