Click here to Skip to main content
16,012,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want assign values to a checkbox at runtime which are stored in a session[""] .

Can you help me?

I want this in c#.net
Posted
Updated 13-Oct-11 21:44pm
v3
Comments
Dalek Dave 14-Oct-11 3:44am    
Edited for Grammar and Syntax.

Try this

CheckBox1.Checked =  (bool) (Session["ChkVal"] ?? false);
 
Share this answer
 
int value=Convert.ToInt32(Session["checkboxvalue"].ToString());

based on the value
checkboxid.Checked=true; //or false
 
Share this answer
 
you can store your value in

C#
Session.Add("myVal","your value");

and at run time
set your checkbox
C#
string val=Session["myVal"].ToString();

checkbox.Checked=val;
 
Share this answer
 
v2
Comments
Dalek Dave 14-Oct-11 3:44am    
Good Answer.
Monjurul Habib 14-Oct-11 3:52am    
nice answer, null check is recommended ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900