GridView DataBinding: Faster with LINQ or Dataset?

7 posts, 0 answers
  1. Brian Thomas
    Brian Thomas avatar
    7 posts
    Member since:
    Jul 2009

    Posted 07 Jul 2009 Link to this post

    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.

  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 09 Jul 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Brian
    Brian avatar
    4 posts
    Member since:
    Jun 2009

    Posted 21 Jul 2009 Link to this post

    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.
  5. Brian
    Brian avatar
    4 posts
    Member since:
    Jun 2009

    Posted 22 Jul 2009 Link to this post

    I was able to call my save functionality in the BindingSource's ListChanged event. For future reference, this is what it looks like:

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

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

    Thank You.
  6. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 24 Jul 2009 Link to this post

    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.
  7. marco
    marco avatar
    33 posts
    Member since:
    Sep 2007

    Posted 25 Jul 2009 Link to this post

    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
  8. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 28 Jul 2009 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready