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