How to check Checkbox state in Datarepeater

Benvor
Benvor used Ask the Experts™
on
Hi Experts

I have a datarepeater(Visual Basic Power packs) on my form and a check box inside the datarepeater. I would please like to know how I can get the 'CheckedState" of the currently selected checkbox. I can get the text of a textbox with this code:

"DataRepeater1.CurrentItem.Controls("DriverTextBox").Text"

Any help would be greatly appreciated

Thanx in advance
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014

Commented:
Did you try getting the CheckedState using this method
"DataRepeater1.CurrentItem.Controls("CheckBox").CheckedState"  ?

Author

Commented:
"'CheckedState' is not a member of 'System.windows.form.controls'"
Most Valuable Expert 2012
Top Expert 2014

Commented:
If
DataRepeater1.CurrentItem.Controls("DriverTextBox")
returns a reference to a text box, DataRepeater1.CurrentItem.Controls("DriverCheckBox") should return a reference to a checkbox, IF that checkbox does exist inside the repeater.
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Author

Commented:
The Checkbox DOES exists inside the repeater. I've tried DataRepeater1.CurrentItem.Controls("CheckedCheckBox").CheckedState and it just says: "'CheckedState' is not a member of 'System.windows.form.controls'". Then I've tried CheckedCheckBox.checkedstate.... butit always returns as "Not Checked"
Most Valuable Expert 2012
Top Expert 2014

Commented:
Give this another try

DataRepeater1.CurrentItem.Controls("CheckedCheckBox").Checked

Author

Commented:
"'Checked' is not a member of 'System.windows.form.controls'"
Most Valuable Expert 2012
Top Expert 2014

Commented:
Another attempt

DataRepeater1.CurrentItem.Controls(CheckedCheckBox.Name).CheckedState
or
DataRepeater1.CurrentItem.Controls(CheckedCheckBox.Name).Checked

Author

Commented:
"Reference to a non-shared member requires an object reference" squiggly lines underneath the "CheckedCheckBox"
Most Valuable Expert 2012
Top Expert 2014

Commented:
What is CheckedCheckBox? Is it a control or the name of a checkbox? Use the name here.

Author

Commented:
CheckedCheckBox is the name of the check box
Most Valuable Expert 2012
Top Expert 2014

Commented:
The error message shows that this is the name of the control rather than the instance. Please try by renaming the checkbox.

Author

Commented:
I've renamed the check box and tried it again but the same error come up
Errors.JPG
Most Valuable Expert 2012
Top Expert 2014
Commented:
Now try this

Checked = Ctype(DataRepeater1.CurrentItem.Controls("CheckedCheckBox"), CheckBox).Checked
or
Checked = Ctype(DataRepeater1.CurrentItem.Controls("CheckedCheckBox"), CheckBox).CheckedState

Author

Commented:
Thank you SOOO much. You really are the best. Thank you

Author

Commented:
Thank you SOOO much. You really are the best. Thank you
Most Valuable Expert 2012
Top Expert 2014

Commented:
You are welcome. I am glad that your problem is solved.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial