Using a checkbox in the gridview template field.

mike55

Contributor
Joined
Mar 26, 2004
Messages
727
Location
Ireland
I have created a template field and inserting a checkbox into the field. I have name the checkbox as: "chkReceipient". I am trying to loop through the grid and check the checkbox in each row to determine if it is checked or not. If the checkbox is checked do something with that row, otherwise move on to the next row.

Here is my code:
Code:
 For inti = 0 To GridView1.Rows.Count - 1
            Dim rowCheckBox As CheckBox = GridView1.Rows(inti).FindControl("chkReceipient")

            If rowCheckBox.Checked = False Then
                dstMembers.Tables("dstMembers").Rows.Add(myRow)
            End If
        Next

The problem that I am having is that the rowCheckBox.Checked is returning the value "False" in all cases evenwhen I check the checkbox.

Any suggestions?

Mike55.
 
Problem solved, never placed the code that was called during the page load in an if not page.ispostback statement. Off to hang my head in shame...

Mike55
 
Back
Top