looks right. you should debug and set a breakpoint on the if statement and see what is actually inside the session variable. perhaps nothing was input in the variable at all in the first place
Please post your code for us to help!!
Mark Answered if it helps - Good luck!
Cheers!
Design And Align - Rob
Marked as answer by cool.asp on Mar 07, 2012 08:52 PM
having trouble... there are so many things to look through in the tree of keys... I can't find what im looking for, its like a maze of keys and Non-PublicMembers...
on the bottom when you're debugging your project, set the breakpoint after when you assign the node.Value to the session variable, there is a window on the bottom of VS called "watch". you can type your variable in there, like
Session["someValue"]
and it will tell you what's in there
Please post your code for us to help!!
Mark Answered if it helps - Good luck!
Cheers!
Design And Align - Rob
In my application (website) sideNav.SelectedNode.Text is the persons Name they are clicking. I need the Value because thats the ID i am trying to get. I tried using (String)Session["someValue"];
and I get the same error :(
on the bottom when you're debugging your project, set the breakpoint after when you assign the node.Value to the session variable, there is a window on the bottom of VS called "watch". you can type your variable in there, like
Session["someValue"]
and it will tell you what's in there
It has the Value I need... in this case "698.23302"
cool.asp
Member
545 Points
190 Posts
Session variable
Mar 07, 2012 05:48 PM|LINK
I have a session variable created when you click on the treenode on the master page (sidenav). Looks like this:
protected void sideNav_SelectedNodeChanged(object sender, EventArgs e) { Session["someValue"] = sideNav.SelectedNode.Value; Response.Redirect("~/Account/Profile.aspx"); }Then I am trying to get the value on the page load of that redirect. That code looks like this:
if (Session["someValue"] != null) { IDLabel.Text = Session["someValue"].ToString(); }I am getting this error... "Input string was not in a correct format." Any assistance is greatly appreciated.
robwscott
Star
8079 Points
1491 Posts
Re: Session variable
Mar 07, 2012 05:55 PM|LINK
looks right. you should debug and set a breakpoint on the if statement and see what is actually inside the session variable. perhaps nothing was input in the variable at all in the first place
Mark Answered if it helps - Good luck!
Cheers!
Design And Align
- Rob
MetalAsp.Net
All-Star
112231 Points
18268 Posts
Moderator
Re: Session variable
Mar 07, 2012 05:56 PM|LINK
cool.asp
Member
545 Points
190 Posts
Re: Session variable
Mar 07, 2012 06:08 PM|LINK
having trouble... there are so many things to look through in the tree of keys... I can't find what im looking for, its like a maze of keys and Non-PublicMembers...
Inayat Rasoo...
Participant
836 Points
285 Posts
Re: Session variable
Mar 07, 2012 06:09 PM|LINK
I tried the same and it worked for me.
Could you please try
sideNav.SelectedNode.Text instead of SideNav.SelectedNode.Value.
If this doesnt work,
Try to convert the data from session to Text
robwscott
Star
8079 Points
1491 Posts
Re: Session variable
Mar 07, 2012 06:12 PM|LINK
on the bottom when you're debugging your project, set the breakpoint after when you assign the node.Value to the session variable, there is a window on the bottom of VS called "watch". you can type your variable in there, like
Session["someValue"]
and it will tell you what's in there
Mark Answered if it helps - Good luck!
Cheers!
Design And Align
- Rob
cool.asp
Member
545 Points
190 Posts
Re: Session variable
Mar 07, 2012 06:14 PM|LINK
In my application (website) sideNav.SelectedNode.Text is the persons Name they are clicking. I need the Value because thats the ID i am trying to get. I tried using (String)Session["someValue"]; and I get the same error :(
cool.asp
Member
545 Points
190 Posts
Re: Session variable
Mar 07, 2012 06:18 PM|LINK
It has the Value I need... in this case "698.23302"
robwscott
Star
8079 Points
1491 Posts
Re: Session variable
Mar 07, 2012 06:28 PM|LINK
are you sure its a string format? and not a node or an object? session variables do not always have to be strings or ints.
Mark Answered if it helps - Good luck!
Cheers!
Design And Align
- Rob
cool.asp
Member
545 Points
190 Posts
Re: Session variable
Mar 07, 2012 06:32 PM|LINK
I have tried:
if (Session["someValue"] != null) { IDLabel.Text = Session["someValue"] as String; }and I also tried:
if (Session["someValue"] != null) { IDLabel.Text = (String)Session["someValue"]; }I also changed the value to text like suggested.
unfortunately still the same error.