Advertisement

03.26.2008 at 05:03PM PDT, ID: 23272582
[x]
Attachment Details

Validating checkbox list in Gridview

Asked by metlogistics in Programming for ASP.NET, Microsoft Visual Basic.Net

Tags: .NET

How can I validate checkboxlist in a giridview. I want to make sure user select atleast one checkbox for each row of Gridview.

I am trying to use a customvalidator inside gridview template.  but its not working...I want each row to be validated and corresponding validator showing the error message.

Thank you..


Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
Code: 
 
  Protected Sub CustomValidator_Checkboxlist_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)
        Dim i As Integer
        Dim selected As String
        
        
        
        Dim gvRow As GridViewRow
        Dim iCounter As Integer
        
        
        For Each gvRow In GridView_Consol_HBL.Rows
            If iCounter = -1 Then
                iCounter = 0
            End If
            Dim cbxList As CheckBoxList = GridView_Consol_HBL.Rows(iCounter).FindControl("CheckBoxList_Consol_Docs")
           
            For i = 0 To cbxList.Items.Count - 1
                If cbxList.Items(i).Selected Then
                    selected = "yes"
                   
                End If
            Next
 
            iCounter += 1
 
    
        Next
        
        
        If selected = "yes" Then
                
            args.IsValid = True     
 Else
            args.IsValid = False
        End If
        
        selected = ""
            
        
    End Sub
[+][-]03.28.2008 at 10:31AM PDT, ID: 21232479

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 05:38AM PDT, ID: 21589044

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, Microsoft Visual Basic.Net
Tags: .NET
Sign Up Now!
Solution Provided By: EE_AutoDeleter
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628