24 December, 2008

Check box value getting in aspx.vb

Dim chkarray As String(), Chkboxes As String
Dim J, iLoop As Integer
Chkboxes = "chkSubjects,chkKET,chkPET,chkPREFCE,chkFCE,chkCAE"
chkarray = Split(Chkboxes, ",")
Dim TutorID As String = "T234"

lblmsg.Text = ""
For J = 0 To chkarray.Length - 1

Dim chk As New CheckBoxList
chk = DirectCast(Me.FindControl(chkarray(J)), CheckBoxList)

For iLoop = 0 To chk.Items.Count - 1

If chk.Items(iLoop).Selected = True Then
Dim qryInsertSubjects As String = "INSERT INTO Subject (ID, Subject) VALUES ('" & TutorID & "','" & chk.Items(iLoop).Value & "')"
lblmsg.Text += qryInsertSubjects + "
"
End If
Next iLoop
Next J

No comments: