RadGrid state on sorting with simple data bound

2 posts, 0 answers
  1. Paresh
    Paresh avatar
    11 posts
    Member since:
    Jan 2009

    Posted 26 Mar 2014 Link to this post

    I was checking Telerik UI for ASP.NET AJAX Q1 2014 trial version for feasibility.

    I was testing RadGrid with my existing code but its behavior is strange compared to MS GridView with Simple-Databinding.

    In my existing code, i am not assigning datasource and not binding grid on particular condition.
    MS GridWorks keeps data as it is but RadGrid clears data.
    I checked that with e.Canceled = True it preserves state.

    the issue occurs when  if at the time of data fetching any error occurs. it clears previous data. in MS grid it keeps data from viewstate.

    Grid should clear data only when .DataBind() or Rebind() called.
    Is there any property or method to make its behavior equivalent.?

    Please find sample code at https://mega.co.nz/#!YYtFCK5Q!PV5XczgbAeyLApV8UtO72O9BBbY6jKl2TJ984703eEo
  2. Viktor Tachev
    Viktor Tachev avatar
    1789 posts

    Posted 28 Mar 2014 Link to this post

    Hi Paresh,

    The behavior you are observing in the sample project is expected as the data source for RadGrid is not set after sorting the second column. Note that when using simple data-binding you must set the DataSource and rebind the grid after every operation (sorting, paging, etc.). The approach is also illustrated in this online demo.

    In order for the functionality to work in the sample you need to remove the 'Exit Sub' line from the SortCommand handler. This would ensure that the DataSource is set and the RadGrid is data-bound.

    Please note that simple data-binding for RadGrid, as the name implies, is recommended to be used in simple scenarios where operations like filtering, grouping, paging, sorting are not necessary. If you have more complex scenario you should consider using advanced data binding by either handling the NeedDataSource event or using declarative data-source.

    Viktor Tachev

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

Back to Top