[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Adding infromation to session state

Posted on 2006-05-22
5
Medium Priority
?
252 Views
Last Modified: 2011-10-03
Hi,
i got a drop down list from which im selecting a employee code out of many in ddl ,now when i select one employee code from ddl  and press a submit button im redirected to different page but im suppose to store the selected employeed code from ddl in my session state while getting redirected. can any one tel me how plz nad syntax plz
0
Comment
Question by:sadat_shaik
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:TornadoV
ID: 16737667
You can do this to store it in session:

string employeeID = whateveryourid is;

Session.Add("employeeID", employeeID)

To retrieve it from session:

if (Session["employeeID"] != null)
{
       Session["employeeID"].ToString();
}
0
 

Author Comment

by:sadat_shaik
ID: 16737678
Iunderstand that tornado but the employee id will be selected from the ddl so how do i set that
string employeeID = /*here i want id that has been selected from a ddl*/

will it be some thing like
string employeeID = ddlEmployee.selecteditems...???
0
 
LVL 11

Expert Comment

by:TornadoV
ID: 16737710
In case your dropdown list has a first item "Select employee" then use this otherwise use ddlSelectedIndex > -1 :

if (ddl.SelectedIndex > 0)
{
        Session.Add("employeeID", ddl.SelectedValue.ToString());
}

0
 

Author Comment

by:sadat_shaik
ID: 16737776
private void btnBuild_Click(object sender, System.EventArgs e)
            {      
    string sEmployeeCode = ddlEmployeeCode.SelectedValue.ToString();
  Session.Add("Employee",sEmployeeCode);
  Response.Redirect("defaultInfo.aspx");
            }
Tornado is this correct like i have to add the emp code selected from the ddl and when he click the buton build then on click event the selected EmpCode should be added to session while getting redirected
0
 
LVL 11

Accepted Solution

by:
TornadoV earned 2000 total points
ID: 16737790
This is correct, once defaultInfo.aspx loads you can retrieve your employee value from Session like this:

if(Session["Employee"] != null)
{
     string employeeID = Session["Employee"].ToString();
}
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question