persist values from one postback to another

G

Guest

Hi,

Not sure if the title makes sense but heres my dilemma. I have two
dropdownlist controls on a webform. I want to make sure that the first
dropdownlist control was clicked on and a value was selected. I want to check
in the second dropdownlist control that this has happened before processing
any info. I thought I would set a boolean in the selected event of the first
ddl control but when the event fires for the second ddl control the boolean
is set back to false due to the page reloading, I assume. How can I persist
that boolean value between postbacks? And for this scenario what is the best
way to achieve my goal if the way im describing is not the best?

Thanks,

JJ
 
G

Guest

The easiest way to handle this is to simply check and ensure the first
control is not set to index 0.

if(ddlFirstControl.SelectedIndex==0)
//code to indicate the user did not touch drop down 1
else
//code to process dropdown 2

If you want to persist a boolean (not necessary if the first drop down has
an invalid value, like "choose one"), you can store it in ViewState.

//in Drop down change event for the first drop down
ViewState("FirstControlChanged") = true;


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top