|
-
Oct 19th, 2010, 04:17 PM
#1
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|