Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with CheckBoxList on web page

Status
Not open for further replies.

jpack23

Programmer
Dec 15, 2004
82
US
I am trying to create a web page that has a checkboxlist which I have bound to a datasource so when the page loads I can get the names of all my employees to appear in the box.

The table which supplies this information also has a field that shows whether or not the employee is at work.

I would like the checkboxlist to show a check mark placed in the box for each employee who is at work

in other words, when the page loads the checkboxlist has every employoee listed and a check mark on those employees who are in the office.

I can load the list of names fine....but I cannot get the check mark in the box.

I have a stored procedure that finds all employees who's "at work" field = 1 and I know how to code to run that stored proc... . I am thinking I just need to know where to put the code? Which Event? If I put it in the page load event it doesnt show the marks.

When I step through the code I notice the my checkboxList.Items.count = 0....

For Each liMark In chklstEMTCheckIn.Items
If liMark.Value = mintEMTID Then
liMark.Selected = True
Else
End If
Next

not sure why this is...almost like the page doesnt know how many items are in the list until its finished loading?


Any help would be great

thanks
joe
 
Use the CheckBoxList's DataBoundEvent. That event fires for each row that is bound to the checkbox. In there you don't need a loop. Just check the value of your boolean column, and if TRUE, then set the box checked.
 
I can create button on the page and put the code in the button event and that does work...but I dont want my users to have to click on a button to put those marks in the check boxes
 
Thanks for your help....problem solved
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top