Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting sessions dynamically 1

Status
Not open for further replies.

tester321

Programmer
Mar 13, 2007
150
CA
Hi i'm in a situation where i need to set the session based off what i'm pulling out of an array.

The session value needs to always be "a", its the session key name that i need to set dynamically, is this possible?

For example something like (ignore my synatax):

foreach item in list[index].attribute1

Session[list[index].attribute1]="a"

Thanks!
 
yes that's works.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
what about setting sessions like this, i can't seem to get this going:
Code:
for (int index = 0; index < listpc.Count; index++)
{
      foreach (string key in Session.Contents){

          if (Session[listpc[index].PieLabel.ToString()] == listpc[index].PieLabel.ToString()) 
            Response.Write(...);
            a1 = 1;
          }

      }
}

 
place this in the page load event, or whever listpc is populated.
Code:
for (int index = 0; index < listpc.Count; index++)
{
   Session[listpc[index].PieLabel.ToString()] = "a";
}

for (int index = 0; index < listpc.Count; index++)
{
   string text = listpc[index].PieLabel.ToString();
   if (Session[text] == "a") 
   {
      Response.Write(text + " = a<br />");
   }
}
if this works then session is enabled and your problem is with the code (either setting or getting values). if this doesn't work make sure session is enabled.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top