I'm having a problem with an ultrawebgrid where when a row is selected the grid.SelectedRows.Count property has a value of 0.
The problem is that the problem only exists in 2 of 3 of my development environments. When I run this from my DEV web server, or in debug against my DEV database and servers, it works fine....grid.SelectedRows.Count == 1 and off we go processing the selected record. But in my BCD and TST environments, running either from my web server or in debug from visual studio, I get a grid.SelectedRows.Count == 0 when selecting from a grid. Exact same code in all environments.
Would a change in the data in the datasource datatable affect the event not populating it correctly?
Hello Robert,
Very hard to tell, since you have identical setups, so I really do not know what could have caused this. I've seen a similar forum post recently, where a customer was getting SelectedRows.Count = 0 even when there were rows selected, and the reason for this was that the grid rebinding after postback occurred prior to his check (rebinding the grid clears SelectedRows collection).
So does this provide some clue (I hope so...)... something along the lines of rebind occuring due to change of data priro to calling SelectedRows.Count on some of your machines?
Hey there. Thank you for the response.
Yes, I had a method that was causing a databind() on the grid and it was wiping out the SelectedRow. Oddly enough, the method was being called in the DEV environment also and wasnt killing the SelectedRow. Strange.
Thanks again,
Rob
Hi,
I have the following function
The thing is that when the grid has no rows it gives an error saying SelectedRows is null.
Regards,
Nicolas
This is weird, doesn'tt the
if (g.SelectedRows != null)
check prevent the grid to enter in the for cycle when there are no rows? You can probably also check if g.Rows.length and or g.SelectedRows.legth > 0 and see if it works.
Also, do you use other 3-rd party controls on the page that emit javasctript? I've seen some libraries like Prototype that cause problems in the
for (var id in ..)
syntax.