Hi Dharmendra,
Thank you as always for your assistance.
Your solution didn't work because I mistakenly left out some important details.
So, the way this works is that user enters data into Name textbox and then enters data into Address textbox.
As soon user does those things, the checkbox is automatically disabled.
If the user does not want to enter data into the Name and Address textboxes, then the user clicks the Checkbox to check the box and checking the box automatically disables the Name and Address textboxes.
Those were the requirements by user and it works very well.
So, the solution you provided (Thank you once again), needs to be modified to check whether the checkbox is enabled or not, whether checkbox is checked or not and whether the Name and Address textboxes are empty or not.
So far, this is my attempt at modifying your code and it is not working:
For Each row As GridViewRow In grvspouse.Rows
Dim namespouse As TextBox = TryCast(row.FindControl("txtspname"), TextBox)
Dim nmespouse As String = namespouse.Text
Dim addressspouse As TextBox = TryCast(row.FindControl("txtspaddress"), TextBox)
Dim addrspouse As String = addressspouse.Text
Dim ckb2 As CheckBox = TryCast(row.FindControl("spDetails"), CheckBox)
Dim checkc As Boolean = ckb2.Checked
If (Not checkc AndAlso ckb2.Enabled = False) OrElse (String.IsNullOrEmpty(nmespouse) AndAlso String.IsNullOrEmpty(addrspouse)) Then
ClientScript.RegisterStartupScript([GetType](), "Confirm", "jAlert('Please enter name and address of spouse or check the checkbox if N/A!');", True)
Return
End If
Next
Each time, I click Submit, I keep getting the alert to please enter name and address...