V
VB Programmer
Simple: I have a datalist that is holding a bunch of job opportunities.
Beside each opp (in the item template) there's a checkbox that says "apply".
After the datalist there's a button that say's "process". I want to LOOP
through each datalist entry and see if the user checked the check box.
Simple.
I wrote the code, but the checked value is ALWAYS False. Any ideas?
Here's the code...
Dim i As Integer, cb As CheckBox, MyJobId As Label, MyJob As Label,
JobAppliedFor As String
For i = 0 To Me.DataList1.Items.Count - 1
cb = CType(Me.DataList1.Items(i).Controls(7), CheckBox)
If cb.Checked = True Then ' THIS ALWAYS SAYS FALSE!!!
' get the job id and the job title
MyJobId = CType(Me.DataList1.Items(i).Controls(1), Label)
MyJob = CType(Me.DataList1.Items(i).Controls(3), Label)
' build a string of everything they checked
JobAppliedFor += MyJobId.Text & ":" & MyJob.Text & ","
End If
Next
Response.Write(JobAppliedFor)
Thanks in advance!
Beside each opp (in the item template) there's a checkbox that says "apply".
After the datalist there's a button that say's "process". I want to LOOP
through each datalist entry and see if the user checked the check box.
Simple.
I wrote the code, but the checked value is ALWAYS False. Any ideas?
Here's the code...
Dim i As Integer, cb As CheckBox, MyJobId As Label, MyJob As Label,
JobAppliedFor As String
For i = 0 To Me.DataList1.Items.Count - 1
cb = CType(Me.DataList1.Items(i).Controls(7), CheckBox)
If cb.Checked = True Then ' THIS ALWAYS SAYS FALSE!!!
' get the job id and the job title
MyJobId = CType(Me.DataList1.Items(i).Controls(1), Label)
MyJob = CType(Me.DataList1.Items(i).Controls(3), Label)
' build a string of everything they checked
JobAppliedFor += MyJobId.Text & ":" & MyJob.Text & ","
End If
Next
Response.Write(JobAppliedFor)
Thanks in advance!