Welcome Guest Search | Active Topics | Sign In | Register

grid - getting the changes status of check boxes Options
tim
Posted: Tuesday, March 2, 2010 7:44:15 PM
Rank: Member
Groups: Member

Joined: 3/29/2009
Posts: 29
Code: Visual Basic.NET

Hi,
I am still struggling to make sense of how to process at the server end the status of the check boxes (ticked/unticked).

I can load the grid and have it display the check boxes correctly (from the db).
Where is gets confusing is after I have unchecked the boxes, then press the update button to initiate the server side logic.

The server starts processing this bit of code:

Grid1.Columns.Item(5) contains the check box.

However, it always says that Grid1.Columns.Item(5) = TRUE, which it is not, it has been unchecked by the user. It was true when it was first loaded, but now it should be false.
Am I missing something? If I know the true state of each checkbox, then I can create the corrected SQL to send to the db, but at the moment, it is gibberish.




For Each item In Grid1.CheckedItems


If (item.Cells(5).Value) Then ' this is always true!


test = item.Cells(0).Value ' I will use this bit to build into my SQL statement

test1 = item.Deleted ' I don't really need this, I just thought it might be of use

End If

for a


We have purchased the licence for Grid & the Ajax uploader. The other aspects of the product seem fine and I'm sure this can be done. I suspect I am on the wrong track.


Thanks


eo_support
Posted: Wednesday, March 3, 2010 11:29:58 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

If the column you are checking is the first checkbox column, then certainly item.Cells(5).Value will always be true because you are looping through Grid1.CheckedItems. Grid1.CheckedItems returns only items that are checked. In another word, your code is checking whether each "CheckedItem" is checked. If you want to check all items, either checked or unchecked, you will need to loop through Grid1.Items, not Grid1.CheckedItems.

You also want to check when you populate your Grid and make sure you only load the Grid from DB when "If Not Page.IsPostBack" is true. Otherwise you will be reloading it from the DB every single time and all changes made by user will be wiped out.

Thanks!
tim
Posted: Wednesday, March 3, 2010 4:01:09 PM
Rank: Member
Groups: Member

Joined: 3/29/2009
Posts: 29
great! Thanks! It was the "If Not Page.IsPostBack" Obviously it was going back to the server and getting the data again, hence the confusing results. As suspected, I was on the wrong track!!!!

Thankyou.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.