A
Andy B.
I have a GridView with 2 databound columns and a templateField with a
checkbox in its ItemTemplate. This gridview is inside step 1 of a wizard
control. What I need to do is when the next button is clicked, have the
CustomValidator check to see if there are any checkboxes in the
templateField column checked. If so, go to the next step. Otherwise
invalidate the page. Here is what I have for the server side event:
Protected Sub CheckBoxCustomValidator_ServerValidate(ByVal source As Object,
ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles
CheckBoxCustomValidator.ServerValidate
' Iterate through the NewsListGridView.Rows property
For Each row As GridViewRow In NewsListGridView.Rows
' Access the CheckBox
Dim cb = DirectCast(row.FindControl("SelectCheckBox"), CheckBox)
If cb.Checked = False Then
args.IsValid = False
End If
Next
End Sub
Problem is that it always makes the page invalid and unchecks all of the
checkboxes that wre checked before validation. Any way to fix this?
checkbox in its ItemTemplate. This gridview is inside step 1 of a wizard
control. What I need to do is when the next button is clicked, have the
CustomValidator check to see if there are any checkboxes in the
templateField column checked. If so, go to the next step. Otherwise
invalidate the page. Here is what I have for the server side event:
Protected Sub CheckBoxCustomValidator_ServerValidate(ByVal source As Object,
ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles
CheckBoxCustomValidator.ServerValidate
' Iterate through the NewsListGridView.Rows property
For Each row As GridViewRow In NewsListGridView.Rows
' Access the CheckBox
Dim cb = DirectCast(row.FindControl("SelectCheckBox"), CheckBox)
If cb.Checked = False Then
args.IsValid = False
End If
Next
End Sub
Problem is that it always makes the page invalid and unchecks all of the
checkboxes that wre checked before validation. Any way to fix this?