hi, I´m trying to use session to store a value (id). The problem is that I have to store it as a string. When trying to use the instance of the id I get the error:
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 156:
Line 157: Nemanet_Navigation newFile = new Nemanet_Navigation();
Line 158: newFile.Nav_pID = (Guid)Session["id"];
Line 159:
Line 160:
This is where I get the id and that seems to work fine. Session["id"] gets the value.
public void treeview_Navigation_SelectedNodeChanged(object sender, EventArgs e)
{
TreeNode node = treeview_Navigation.FindNode(treeview_Navigation.SelectedNode.ValuePath);
NavTreeNode nNode = node as NavTreeNode;
Session["id"]=((TreeView)sender).SelectedValue.ToString();
}
But this code does not seem to work. I get the error mentioned above.
protected void Button1_Click(object sender, EventArgs e)
{
Nemanet_Navigation newFile = new Nemanet_Navigation();
newFile.Nav_pID = (Guid)Session["id"];
}