Hi,
I've got a table and a column called "Servers". How can I get each of the server and then display each of them in check box?
Example:
Server 1 [checkbox]
Server 2 [checkbox]
.
.
.
.
Server 10 [checkbox]
Regards,
Roger
Printable View
Hi,
I've got a table and a column called "Servers". How can I get each of the server and then display each of them in check box?
Example:
Server 1 [checkbox]
Server 2 [checkbox]
.
.
.
.
Server 10 [checkbox]
Regards,
Roger
How about bind the table with CheckBoxList?
Ya.. I've just discovered it.. Thanks a lot dude.
But another problem seems to appear now.
You see, in my page, there are dropdown list box and check boxes.
Dropdown list box contains all about software.
Checkbox list contains all servers.
However, what I want is that when a person clicks on the selected software, the checkbox list will then do a SQL command to search for Server that is using the software. Is there anyway to make it work? I've got no ideas at all.
Regards,
Roger
I know that I need to cater coding to detect what the user has selected in the drop down list. But how do I do it? Can anyone guide me?
The dropdownlist has a SelectedIndexChanged event in which you can read the selected value and then populate the checkboxlist depending upon that value. Is that what you were looking for?
Ya... I've tried to use SelectedIndexChange.. But it does not run at all. When I insert break point, it simply skipped through the SelectedIndexChange event.
Do you have the AutoPostBack property set to True for the dropdownlist?
Ya. I've got it to work. But why must I set the autopost back?
Can anyone please explain?
did the AutoPostBack fix the problem?
When the AutoPostBack property is true for a dropdownlist, the page posts back to the server when the index is changed, allowing you to carry any values with it. you can actually see the behavior when it occurs because the page 'reloads' itself in a way. give it a try (with AutoPostBack set to True of course)
Yes, the auto post back fixed everything. But how do I write a loop to check if the check boxes are checked. If the check box is checked, then it will add into the database.
Regards,
Roger
Do you have checkboxes in your DropDownList? i didn't think you could do that in webforms :ehh: Or do you have a checkbox list?
Sorry if I did not make things clear. I've got a checkbox list and how do I do a loop to check which checkbox is checked.
Oh I found it. More information can be found here
Thats cool. I didn't reread the earlier posts :)
Try this to itterate through the checkboxes:
VB Code:
dim i as integer For i = 0 To CheckBoxList1.Items.Count - 1 If CheckBoxList1.Items(i).Selected Then 'code here End If Next
Ahh good job! :)
Thanks a lot dude. :thumb:
Anytime friend! :wave: