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?
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.
Re: Retrieve selection in grid impossible due to postback
That's what I thought, but if their support staff doesn't answer this question within a week I'm starting to doubt it...
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
Re: Retrieve selection in grid impossible due to postback
Quote:
Originally Posted by
gep13
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.
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