Welcome Guest Search | Active Topics | Sign In | Register

checkbox selection to change records in database Options
tim
Posted: Tuesday, February 23, 2010 1:24:44 AM
Rank: Member
Groups: Member

Joined: 3/29/2009
Posts: 29
Hi,
I have put a grid together that uses a checkbox to show me a set of checkboxes that correctly represent the data in a table.
What I am trying to do now is allow the user to change his selections by checking/unchecking the checkboxes and then saving then posting the change to the database.

I have found GetCheckedItems, but can't see how I should use it?

I also though this sort of logic would work:

For Each item In Grid1.CheckedItems

If item.Cells(5).Value = True Then

test = item.Cells(0).Value

End If

Next item


But it just thinks item.Cells(5).Value = True is always true!

I'm sure this must be very simple.....

Code: Visual Basic.NET
eo_support
Posted: Tuesday, February 23, 2010 8:30:55 AM
Rank: Administration
Groups: Administration

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

CheckedItems returns all items whose first check box columns are true. So if you have multiple columns that are checkbox column, then only the first one is considered. If you want to check other columns, you can loop through Grid1.Items.

Thanks!
tim
Posted: Wednesday, February 24, 2010 1:44:53 AM
Rank: Member
Groups: Member

Joined: 3/29/2009
Posts: 29
Thanks! But unfortunately I am getting lost. I really need an exmple bit of code to get me under way here.

Anything I am trying is not returning what I expect.

somehow I have to process the "itemchanged" event?


But how do I do that? I assume this is a server side piece of logic that is
done when the users presses the magic update button, but I need an example bit of code.

Basically, I must have to loop through all of the rows and detect the clients current status of the check boxes. Once I can see that, I can convert that into the appropriate SQL.

Thanks.
eo_support
Posted: Wednesday, February 24, 2010 7:14:27 AM
Rank: Administration
Groups: Administration

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

We do not know how we can explain CheckedItems better. You just loop through it and there is nothing else to it. Here is a working example:

http://demo.essentialobjects.com/Default.aspx?path=Grid\_i1\_i16

You do not have to handle ItemChanged event. It's just one of the options. You can just handle whatever else event that triggered the post back and loop through the Grid's ModifiedItems to update your backend db.

Thanks!


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.