By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,456 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Checkbox Value - Please help

P: n/a
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!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <am**@yahoo.com> wrote in message
news:uL**************@TK2MSFTNGP10.phx.gbl...
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!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2

P: n/a
Thank you so much!!!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

P: n/a
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" <am**@yahoo.com> wrote in message
news:uL**************@TK2MSFTNGP10.phx.gbl...
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!


*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!

.

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.