Results 1 to 6 of 6

Thread: Retrieve selection in grid impossible due to postback

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Retrieve selection in grid impossible due to postback

    Hi,

    I am using a third party grid (UltraWebGrid by Infragistics if you happen to know it...) which allows the user to select rows. I also have a button above the grid that should be used to control the selected rows. For the sake of example, let's say I have a 'Delete' button that should set a 'deleted' flag in the items in the grid (so don't actually delete them from the grid).

    In winforms this would be really easy, just handle the button's Click event, check the selected rows and do something with them:
    Code:
    Private Sub DeleteButton_Click(..) Handles DeleteButton.Click
       For Each row In grid.SelectedRows
          '...
       Next
    End Sub
    However, as I start finding out more and more, it seems it's not as simple in asp.net...

    I basically have the same code as above, but there is one major problem: when the button is clicked, a postback occurs and the grid looses its selection. Hence, SelectedRows never contains any rows!

    I've looked far and wide and there does not seem to be any way to get the grid to retain its selected rows during a postback. So I need a different solution. I've thought of two:

    1. Return 'false' via javascript in the OnClick of the button, disabling postback,
    2. Remember the selected rows in a session variable and retrieve them in the button click event.

    Option 1 of course fails because when I do that, the Click event is never raised.

    Option 2 also fails because for that I would need to handle the SelectedRowsChanged event. If I do that, a postback occurs every time the selection changes, and even then, in the SelectedRowsChanged event handler, the SelectedRows is always empty, the rows are lost again.


    I'm truly lost here. This seems to be the number one reason to ever use a grid, besides showing data, yet it doesn't seem to be possible...

    I am using a third party grid as I said, and I have asked my question on their forums but to be honest their forums suck, I haven't received a single reply in over a week. I think there must be a solution regardless of what grid I'm using, so I decided to ask here...

    Any help?

  2. #2
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Retrieve selection in grid impossible due to postback

    I haven/t ever used the UltraWebGrid control, but with the normal ASP.NET GridView I've never had problems retrieving the selected rows or anything else inside the grid after postback. I'm sure the UltraWebGrid controls must also be having adequate support as that is one of the basic things one would do with the grid.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  3. #3

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Retrieve selection in grid impossible due to postback

    Nick,

    Have you paid for this control? Like Pradeep, I have never used it, but if you have paid for it, then you should be able to get some support for it.

    Gary

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Retrieve selection in grid impossible due to postback

    Quote Originally Posted by gep13 View Post
    Like Pradeep, I have never used it, but if you have paid for it, then you should be able to get some support for it.
    Yeah, you'd think so right..? Apparently not... They have a forum and everything, but my post has not been answered by anyone in ... 2 or 3 weeks? I dunno, I've given up on them.

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Retrieve selection in grid impossible due to postback

    That is very poor.

    As an alternative, I have used the Telerik controls before, and I have found their support to be excellent. Obviously that doesn't help you in your current situation, but something to think about as an alternative.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width