Checkbox Value - Please help

  • Thread starter Thread starter Amy Snyder
  • Start date Start date
A

Amy Snyder

For what I thought would be a very simple task is turning out to be very
frustrating. I have been trying for a day now to extract checkbox
values from my form and nothing is working.

On my form load I am setting the values of my checkboxes:
chk1.Attributes.Add("checkValue", "151010")
chk2.Attributes.Add("checkValue", "151020")
chk3.Attributes.Add("checkValue", "151030")
chk4.Attributes.Add("checkValue", "151040")
chk5.Attributes.Add("checkValue", "151050")
...

When the submit button is clicked, I want to loop through all checkboxes
and retrieve the value of the checkboxes that were selected.


Dim ctrl As New Control
Dim chk As New CheckBox
Dim strIndustry As String

' Loop through all the controls on the panel.
' Create the string for the SQL statement.
For Each ctrl In pnlSearchResults.Controls
If TypeOf ctrl Is CheckBox Then
' Get value of checkbox
End If
Next

I have tried a few different ways and keep getting errors. Could
someone please provide a solution? Thanks!
 
Hi there,
Here is what you need.

' assuming page tracing is enabled...

For Each ctrl In pnlSearchResults.Controls
If TypeOf ctrl Is CheckBox Then
chk = CType(ctrl, CheckBox)
If chk.Checked Then
Trace.Warn(chk.Attributes("checkValue"))
End If
End If
Next

Regards
Claudio
 
I want to get the checkbox status from the datalist web
control when checkbox is placed int the item template of
the datalist.

How can i achieve that?
I have used findcontrol method but it did not help me what
is the other alternate?

Thank you

-----Original Message-----
Hi there,
Here is what you need.

' assuming page tracing is enabled...

For Each ctrl In pnlSearchResults.Controls
If TypeOf ctrl Is CheckBox Then
chk = CType(ctrl, CheckBox)
If chk.Checked Then
Trace.Warn(chk.Attributes("checkValue"))
End If
End If
Next

Regards
Claudio

Amy Snyder said:
For what I thought would be a very simple task is turning out to be very
frustrating. I have been trying for a day now to extract checkbox
values from my form and nothing is working.
 
Back
Top