Click here to Skip to main content
11,701,616 members (71,352 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP VB.NET
I am working on a survey and a have a chechkbox list, I need at the and to prevent that tthe chechkboxes are not left unchechked.

in the asp net code I have chosed as <asp:customvalidator>

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        For Each item As DataListItem In DataList1.Items
            If item.ItemType = ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem Then
                Dim questionid As Integer
                Dim choiceid As Integer = 0
                Dim choicetext As String = ""
                questionid = CType(item.FindControl("Label3"), Label).Text
                Dim anstype As HiddenField = item.FindControl("HiddenField1")
                Select Case anstype.Value
                    Case "S"
                        Dim rbl As RadioButtonList = item.FindControl("RadioButtonList1")
                        If rbl.SelectedValue = "" Then
                            choiceid = 0
                            choiceid = rbl.SelectedValue
                        End If
                        SaveAnswer(questionid, choiceid, "")
                    Case "M"
                        Dim cbl As CheckBoxList = item.FindControl("CheckBoxList1")
                        For i As Integer = 0 To cbl.Items.Count - 1
                            If cbl.Items(i).Selected Then
                                choiceid = cbl.Items(i).Value
                                '"Ve molime dopolnete gi site prasanja")
                            End If
                            SaveAnswer(questionid, choiceid, "")
                    Case "T"
                        Dim txt As TextBox = item.FindControl("TextBox1")
                        choicetext = txt.Text
                        SaveAnswer(questionid, 0, choicetext)
                End Select
            End If
        DataList1.Visible = False
        Label5.Text = "Ви благодариме за учеството во анкетата!"
    End Sub
Posted 9-May-13 22:02pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

YOur question isn't clear. Give a brief description of your problem. I'll try to provide a solution.
richcb at 10-May-13 15:55pm
Why did you post a comment as a solution to a question? Do you see a problem in that login?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 324
1 Maciej Los 275
2 Sergey Alexandrovich Kryukov 250
3 Mika Wendelius 189
4 CHill60 110
0 OriginalGriff 8,274
1 Sergey Alexandrovich Kryukov 7,317
2 CPallini 4,912
3 Maciej Los 4,146
4 Mika Wendelius 3,556

Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 10 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100