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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get value of selected dynamic checkboxes?

Status
Not open for further replies.

frmsasp

Programmer
Sep 2, 2005
9
IN

Hello there,

Currently I am working with the project which needs dynamically generated checkboxes and i have generated dynamic checkboxes but i am facing problem with getting the vaue of selected checkboxes.

Problem is described below in detail to easily understood, so please let me know if you come to know...

Example:
I am creating a form to assign rights to site admin for managing different module of the site from back end. Please have a look at attached file to better understand the structure of admin rights form which i used.

I had created checkbox dynamically with below statement FOR EACH Module.

lblCheck.Text += "<input type='checkbox' name='chk[" + daDetail["Module_id"] + i.ToString() + "]' value='A'>Add
lblCheck.Text += "<input type='checkbox' name='chk[" + daDetail["Module_id"] + i.ToString() + "]' value='E'>Edit
lblCheck.Text += "<input type='checkbox' name='chk[" + daDetail["Module_id"] + i.ToString() + "]' value='D'>Delete
lblCheck.Text += "<input type='checkbox' name='chk[" + daDetail["Module_id"] + i.ToString() + "]' value='S'>Search

Say my Module_Id = 12

After form submit I got value with
form.querystring["chk121"]; form.querystring["chk122"];
form.querystring["chk123"];
form.querystring["chk124"];

But I want to use foreach loop for getting the values of each selected checkboxes Because there are more then 50 moudles. so please,let me know how to do this? Main problem is that I don't know how many total checkbox generated dynamically, that is why I have to use foreach or for loop.

Any help, advice or pointers on this matter would be highly appreciated.

Thanks,
Paresh
 
In thread855-1136311, I suggested that you use a CheckBoxList and showed you how to dynamically add checkbox's to the list. Is there a reason you have not implemented that suggestion, as if you did it would make it very easy to find which boxes were checked?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top