Grid View filter posting wrong rows?

Posted by: tlbradshaw on 10 September 2017, 11:33 am EST

  • Posted 10 September 2017, 11:33 am EST

    I have a Grid View bound to a data source on my web page.  I can filter by values just fine, but when I do any action that submits the page, I get the wrong rows returned in the Rows collection.  For example, if I filter 100 rows by a value that will give me 10 rows, and then click a button for submit, I get a gridview.rows collection with the first 10 rows, but they are the first 10 rows of the data source.


     


    Here is the code I'm using:


     


    protected void bn1_click(object sender, EventArgs e)



      foreach (C1GridViewRow GR in C1GridView1.Rows)


      {


       string value = GR.Cells[4].Text;


      }


    }


    The problem is that the data I'm parsing is from the first row in the UNFILTERED data table and each addition row is the next in the UNFILTERED data table to the COUNT of the filtered rows.


     


    Am I doing something wrong?


    I am using version 3.5.20101.72 of the C1.Web.UI.3.dll.

  • Replied 10 September 2017, 11:33 am EST

    Hi,


    Unfortunately nothing can be actually done here, native callbacks mechanism in ASP.NET does not persist


    control state (checkboxes in our case). If you want to have contol state persisted you need to implement


    special code for that. C1GridView itself has a mechanism to persist its own state but cannot do the


    same for child controls.


    Perhaps the best way here would be not to use grid callbacks but use an UpdatePanel control instead.


    >> If I remove the callback then the filter works as expected but the filter drop downs will not clear the screen after making a selection.


    Is the grid contained in UpdatePanel? The issue is fixed in build 2.0.20102.187, please wait for the update.


    Regards,


    Sergey.

  • Replied 10 September 2017, 11:33 am EST

    Hi,


    looks like you perform filtering via callbacks, between callbacks control ViewState is not persisted, that is why cells initially contain the very first text. Try to call C1GridView.DataBind() before foreach statement.


    Regards,


    Sergey.

  • Replied 10 September 2017, 11:33 am EST

    I have removed the callback option from the control and it works as expected.  Thank you.

  • Replied 10 September 2017, 11:33 am EST

    I have check boxes that get loaded during the databind, and can be "Unchecked" by the user before the post back (commit).  If the user "Unchecks" the boxes, then during the for each loop that row is not processed.


    if I call databind before my foreach statement, the grid values revert to the loaded values overwriting the selections from the users.


    If I remove the callback then the filter works as expected but the  filter drop downs will not clear the screen after making a selection.

  • Replied 10 September 2017, 11:33 am EST

    I've got the same problem. I've set callback options to none and it works by loose the ajax functionality.


    It also happens if you have more tha one page, go to any page that is not the first and do a postback from a linkbutton in a template field in the grid, it will show afterwards the first records but the grid will still be at the page you were.


    I'm using version 72 also but it happens at lest from version 64.

  • Replied 10 September 2017, 11:33 am EST

    Hi,


    I have checked the grid with the following sample code:



       AllowPaging="true" CallbackOptions="Paging" VisualStyle="">


       


           


           


           


               


                   


               


           


       



    Launch the sample, go to 5th page, press a button in TemplateField, postback occurs,


    grid is still on the 5th page showing data of the 5th page.


    Regards,


    Sergey.

  • Replied 10 September 2017, 11:33 am EST

    Is this on the plans for an future development?  I really like the AJAX Wait Spinner.  It makes the Grid View feel a lot more polished rather than using an Update Progress template.  


    However, if I can't get the data that has been filtered on the screen to post back, then I'm left with no choice but to turn off all callbacks.

  • Replied 10 September 2017, 11:33 am EST

    Hi,


    No, we don't plan this. C1GridView should not show wait spinner during postback, especially for another control.


    BTW, why don't you like UpdateProgress here? I think that basing on it your can implement something similar to C1GridView wait spinner, just put the same icon into ProgressTemplate and center it to C1GridView when button is pressed.


    Regards,


    Sergey.

  • Replied 10 September 2017, 11:33 am EST

    I am now using an UpdateProgress panel here.  I liked the fact the the wait spinner was centered on the C1GridView control and looked like it was part of the control.  The Update Progress panel that I have used greys out the entire screen and then centers a gif on the screen.  Like I said... the wait spinner just looks a little more polished than what I had.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels