c# - Setting up Session Variables -


i have radiobuttonlist 2 options -beach bach -bush bach

i want create 2 session variables doing right

session["beachbach"] = bachradiobuttonlist.selectedvalue = "beach bach"; session["bushbach"] = bachradiobuttonlist.selectedvalue = "bush bach"; 

so if users press chose "beach bach", 1 added session["beachbach"] same goes bush bach

or need create 2 radiobuttonlist??

thanks

i think want == instead of =:

session["beachbach"] = bachradiobuttonlist.selectedvalue == "beach bach"; session["bushbach"] = bachradiobuttonlist.selectedvalue == "bush bach"; 

otherwise you're setting selectedvalue of each radio button storing that string in session variables. if use == comparing values , storing true or false in session variables.

if really want store 1 or 0 (which don't recommend - bool values should work fine , make server side code cleaner) use (condition) ? (true) : (false) ternary operator:

session["beachbach"] = bachradiobuttonlist.selectedvalue == "beach bach" ? 1 : 0; session["bushbach"] = bachradiobuttonlist.selectedvalue == "bush bach" ? 1 : 0; 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -