C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Active Directory »

Select/Deselect all Checkboxes at Server side in ASP.NET using C#


Posted Date: 15 Mar 2008    Resource Type: Code Snippets    Category: Active Directory
Author: KalyanMember Level: Gold    
Rating: 1 out of 5Points: 10



Some time we come across with the scenario where we need the function to select\deselect the checkboxes
from the server side code.The following code is going to describe the scenarion where we have one Panal Control which is having the multiple checkboxe

Code sample :-



//Drag and drop a panal control in asp.net web page

//Following will be the auto generated code with user defind controlName

protected System.Web.UI.WebControls.Panel PnlTimeExpence;

//Decleare one checkbox object

CheckBox chkList1;

//write a code to add dyanamic checkboxes



..
..
.. //code to add dyanamic controls(checkboxes). Check link above for adding dynamic checkboxes.

..

..

//Now we have a Panel control ready with multiple checkboxes.

//Fuction to select\Deselect checkboxes

private void SelectAllCheckBoxControls(Control parent,bool checkedVal)

{

try

{

string strLeave=string.Empty;

foreach (Control child in parent.Controls)

{

if (child.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox"))

{

CheckBox chk = (CheckBox)child;

chk.Checked=checkedVal;

}

}

}

catch(Exception exp)

{

throw new Exception("SelectAllCheckBoxControls " + exp.Message);

}

}

//Generate event on which we want to perform the select\deselect operation

//Following code is using a checkbox control to select \deselect the Event

private void chkReport_CheckedChanged(object sender, System.EventArgs e)

{

try

{

//Calling a userdefind function

SelectAllCheckBoxControls(PnlTimeExpence,chkReport.Checked);

}

catch(Exception exp)

{

throw new Exception("chkReport_CheckedChanged " + exp.Message);

}

}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Server side  .  Selection  .  Checkbox  .  Asp.net  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Go Back to Previous Page
Previous Resource: DBTask in C#
Return to Discussion Resource Index
Post New Resource
Category: Active Directory


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use