First Row Duplicated on Sort or Filter

3 posts, 1 answers
  1. Tyson
    Tyson avatar
    9 posts
    Member since:
    Apr 2007

    Posted 28 Jul 2009 Link to this post

    I have been developing a control, using Radgrid, which will get its list of columns and mappings from a database. We had previously done this using the Radgrid control, wrapped in a composite control, but there were several complications, the work arounds for which turned the control into a rather daunting piece of code. We also had many difficulties in getting the filtering to work properly with the dynamic databinding and the dynamic fields. The result of all this was a difficult to maintain code base, with no ability to do filtering (weren't using Linq at that time).

    Since then, I have rewritten the control, removing much of the logic which was extraneous to the function of the grid, and made it to use databinding through Linq to an IEnumerable object. I had alot of success inheriting from Radgrid (which I know you don't officially support) and have followed the recommendations I could find as best I could. There's really only one issue now that I am having difficulty getting past, and I'm not really sure where to look.

    When there is a postback from either the built in Radgrid sort or Paging, the very first record in the result gets duplicated when it is rendered. The dataset it is bound to has 100 records, yet it renders 101 records, with two occurances of the first record on the first page. If I do a postback using either of the other controls built in (like a custom checkbox column), then the first record is not duplicated. The same is true on consecutive searches, no duplicate record.

    I was wondering if you had a hint as to where I can look to see the process of binding the datasource to the grid, or perhaps you have an idea as to what is differrent on a sort or paging event, as opposed to a CheckChanged event. The only thing I can see is that I am calling the Rebind method on the CheckChanged event (which is bubbled to the enclosing user control) and for the Radgrid Paging and Sorting postbacks it is calling CreateTableView and NeedDataSource. On CreateTableView, I am building a GridTableView object based on the configured columns in the database and returning this, and on the NeedDataSource I am pulling the datasource from the session (and have verified this contains only 100 records).

    Any ideas would be appreciated.
    Thanks,
    Tyson Brown
  2. Tyson
    Tyson avatar
    9 posts
    Member since:
    Apr 2007

    Posted 28 Jul 2009 Link to this post

    Upon further research, I found that on the NeedDataSource event handler, I was setting the datasource to an IQueryable object (IList.AsQueryable()), and on the others (the ones where it was not duplicating the first record) I was setting it to IList. For some reason the AsQueryable(), although it was producing 100 records, was being rendered with the first record duplicated one time. I'm not sure why this is, but I'm sure I'll have to face that hurdle in order to get nested master / detail tables to work properly. When I set the data source to the IList, it worked fine on all postbacks.

    If you have ideas as to why the AsQueryable() would cause an issue such as this, please let me know.

    Thanks,
    Tyson
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 31 Jul 2009 Link to this post

    Hello Tyson,

    Unfortunately I'm unable to re-create the described behavior locally from the given details. I have attached a simple test page, please take a look maybe I'm missing something obvious.

    Also you may consider sending us (attached to a formal support ticket) a small runnable project in which the behavior can be observed. This way we will be able to gather more details about your case and implementation and provide you with more to-the-point answer.

    All the best,
    Rosen
    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