This is a discussion on "How to get value of selected dynamic checkboxes?" within the ASP.NET Forum section. This forum, and the thread "How to get value of selected dynamic checkboxes? are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
How to get value of selected dynamic checkboxes?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
How to get value of selected dynamic checkboxes?
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 |
|
#2
|
|||
|
|||
|
Re: How to get value of selected dynamic checkboxes?
Why dont you use a placeholder and dynamically add the checkboxes to that, then you can count the controls on the page and filter out the checkboxes?
Just a thought... |
![]() |
| Tags |
| value, selected, dynamic, checkboxes |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Selected radio button value | Pugger | JavaScript Forum | 8 | Nov 3rd, 2007 14:16 |
| Making CheckBox Selected | anilreddy76 | JavaScript Forum | 4 | Sep 11th, 2007 05:20 |
| Required text field if Other selected from a list | redlevel | JavaScript Forum | 3 | May 16th, 2007 16:32 |
| How to view selected field only? | awiezzz | Classic ASP | 1 | May 13th, 2007 17:12 |
| display on the page an item selected with a form drop down | antonyx | JavaScript Forum | 1 | Aug 22nd, 2006 16:05 |