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

GridView DataBinding: Faster with LINQ or Dataset?

6 Answers 384 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Brian Thomas
Top achievements
Rank 1
Brian Thomas asked on 07 Jul 2009, 08:36 PM
I have a project that needs expedited and I'm new to Telerik components so I need some advice please.

I was hoping to use LINQ to populate my grid and I'm using a binding source as an intermediary. The grid was not saving my data and it is not clear by the documentation on how to do this. However, it appears, via forum suggestions, that I'll need to create some type of saving mechanism in the RowValidated event to accomplish this if I use LINQ.

So, would it be faster for me to use a dataset and tie the grid into that instead? Are there any considerations when doing it this way? I'm hoping that I can create the dataset, tie the grid to it and I'll be done.

Thank You.

6 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 09 Jul 2009, 03:26 PM
Hi Brian Thomas,

RadGridView is implemented to support native IBindingList objects and it is best support for DataSet/DataTable ADO.NET objects.

You can bind LINQ object using BindingSource and all CRUD operation will be supported, but RadGridView is not responsible for saving data. This functionality is coming from DataContext object or other LINQ provider implementations.

Greetings,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Brian
Top achievements
Rank 1
answered on 22 Jul 2009, 03:27 AM
Thanks for the post. However, I have some issues with the response. I would've addressed them earlier but I didn't for my lack of knowledge about the grid and LINQ. So, I've done a lot of research, became side-tracked while working with the grid, and I'm now back to the grid trying to tackle something that should be very simple.

First, you stated, "RadGridView is not responsible for saving data". That is fine, but it would be nice if you would be able to describe or direct me to information (tutorial) that would help me to know how and where in the grid I can call my save functionality. I would imagine that more than one person needs to save data. I have seen a few posts that direct me to saving data through the RowValidated event. For an earlier piece of my project, I did implement this by calling my LINQToSQL datacontext's submitchanges() method and that "seemed" to work.

However I am doubting that it worked because I am at another situation and am befuddled. In this situation, I created a LINQ query to get data from a view that resides in SQL Server. My grid is tied to a binding source, and the binding source's datasource is tied to the fore mentioned LINQ query. As I edit through the data, I want to create functionality to save the data using the appropriate stored procedure. I attempted to call my stored procedure/save method through the RowValidated event but am having problems.

The problem is that I'm attempting to access a cell's changed value through the rowvalidated event's arguments property and it isn't accurate--it is the old value. I see there is a cell changed event but it doesn't make much sense to post data back to the server for every cell change. This save process is making it very difficult to complete this portion of my project. It should be easy: in the row validated, get the e.Row["MyField"].Value and post it to to the database by calling my stored procedure/saved method.

Any ideas? Thank You.
0
Brian
Top achievements
Rank 1
answered on 22 Jul 2009, 01:20 PM
I was able to call my save functionality in the BindingSource's ListChanged event. For future reference, this is what it looks like:

private void bindSourceLineCode_ListChanged(object sender, ListChangedEventArgs e)  
        {  
            vw_LABOR_EXTENSION le = null; //My labor LINQ class from my data context  
            int NewLaborExtID = -1;  
 
            if (e.ListChangedType == ListChangedType.ItemChanged)  
            {  
                le = (vw_LABOR_EXTENSION)radGrdVwAdjustLineCode.Rows[e.NewIndex].DataBoundItem; //cast the radgridview row that was changed into my LINQ class  
                 
                //Call my update function which calls my stored procedure  
                //and return the new id if record is new, otherwise  
                //it returns the current id. If record is new my stored proce  
                //creates the record.  
                NewLaborExtID = dbLineCode.UpdateLaborExtension(le);  
                le.LE_ID = NewLaborExtID; //store the id into my LINQ class and  
                                         //because the rad grid view is based  
                                         //of of it, the grid automatically sees the new value  
 
            }  
        } 

However, I would still like to know why the row validated event contains the old values. Any ideas?

Thank You.
0
Julian Benkov
Telerik team
answered on 24 Jul 2009, 11:21 AM
Hi Brian,

We continued with the tests for RowValidated event and we have not found any problems with row values in the current edition of RadGridView. If you continue to experience problems, please send us a sample application with your data objects so that we can reproduce the issue locally. Thank you very much in advance.

Kind regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
marco
Top achievements
Rank 2
answered on 25 Jul 2009, 06:22 PM
Hi Julian,

is there any fast and simple way to make a two way databinding in the gridview?
I mean not only view but also have an automatic update on cell/row edit
the same way as it is possible with the asp.net radGrid.

generally I use dataset to interface to data.

thanks,

marco
0
Julian Benkov
Telerik team
answered on 28 Jul 2009, 11:53 AM
Hello Marco,

Currently you can use RowValidated and RowsChanged events of RadGridview to support this functionality. We are currently researching how to implement AutoUpdate event with support for the most frequently used data bound objects (e.g. ADO.NET, Entity framework) and Telerik OpenAccess product.

Sincerely yours,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Brian Thomas
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Brian
Top achievements
Rank 1
marco
Top achievements
Rank 2
Share this question
or