User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 392,314 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,948 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting

how to get value of all selected checkbox?

Join Date: Nov 2005
Location: Mountain View, CA
Posts: 47
Reputation: kedar_challa is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 1
kedar_challa's Avatar
kedar_challa kedar_challa is offline Offline
Light Poster

Re: how to get value of all selected checkbox?

  #2  
Nov 9th, 2005
Originally Posted by frmsasp
Hello there,

I am using ASP.NET with C# and facing below problem. I am not able to get values of selected checkboxes which are generated dynamically.
Pls have a look at the image attached with the message...

Waiting for your reply....

Thanks,
Paresh

Hi Paresh,

I dont know how you are adding the dynamic controls at the runtime. But while you are create the new Checkbox Object to add to the form, append the same object to a static collection object like Hash Table.

protected static Hashtable mRoleCheckBoxList=new Hashtable();
mRoleCheckBoxList.Add(RoleName, NewCheckBox);

Here mRoleCheckBoxList is a global static object of a HashTable.


now when ever you did a postback to the page u can get the values using following.
IDictionaryEnumerator RoleCheckBoxEnumerator = mRoleCheckBoxList.GetEnumerator();
while ( RoleCheckBoxEnumerator.MoveNext() )
{
HtmlInputCheckBox RoleCheckBox=(HtmlInputCheckBox)
RoleCheckBoxEnumerator.Value;
string BoxRoleName=(string)RoleCheckBox.Value;
if(RoleName.Equals(BoxRoleName))
{
RoleCheckBox.Checked=true;
break;
}
}

Thanks,
Kedar
Reply With Quote  
All times are GMT -4. The time now is 10:26 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC