Hello stackoverflow users hope you can help me.
I have populated a treeview control with some data from my database.
and it works just fine alle the nodes a created but now i need a category id stored in the node. here is a short description of how I make the nodes.
TreeNodeCollection nodes = new TreeNodeCollection();
TreeNode tn = new TreeNode();
tn.Text = "<span onclick='return false;'>"+ c.Category_Name +"</span>";
tn.Value = c.Category_Id.ToString();
nodes.Add(tn);
then when i try to get the value out again for the example here where i will delete the node from the database ill need the selected category id.
protected void btnDeleteCategory_Click(object sender, ImageClickEventArgs e)
{
TreeView1.Nodes.Remove(TreeView1.SelectedNode);
string categoryId = TreeView1.SelectedNode.Value;
// run delete method
}
but now the SelectedNode.Value is emty ” “. but before when i set the value it vasent.
I was thinking it can be something with when it populate the treeview, but cant see where it should be ?
Capture the id before removing the node.