Mohamad Javad
Top achievements
Rank 2
Iron
Iron
Iron
Mohamad Javad
asked on 10 Jul 2014, 06:30 AM
hi
when the webpage is postback the treeview , never show which, node is selected before the postback the page.
how to save state tree view node selected, after postback page?
when the webpage is postback the treeview , never show which, node is selected before the postback the page.
how to save state tree view node selected, after postback page?
6 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 10 Jul 2014, 07:48 AM
Hi Mohamad Javad,
You can store the state of RadTreeview in a session variable as follows.
And you can restore the RadTreeView state from the session variable in appropriate event like this.
Let me know if you have any concern.
Thanks,
Shinu.
You can store the state of RadTreeview in a session variable as follows.
Session["myTreeView"] = rtreeDemoList.GetXml();And you can restore the RadTreeView state from the session variable in appropriate event like this.
string treeViewState = (string)Session["myTreeView"];rtreeDemoList.LoadXmlString(treeViewState);Let me know if you have any concern.
Thanks,
Shinu.
0
Mohamad Javad
Top achievements
Rank 2
Iron
Iron
Iron
answered on 10 Jul 2014, 09:07 AM
thanks. but I've not helpful.
how to set the special node,is selected in c# code.
Almost like the code below is my requirement:
RadTreeView1 . SelectedNode . Node . Value = 7 ;
for set for example:node with value=7 is selected with click button or set this after postback page.
how to set the special node,is selected in c# code.
Almost like the code below is my requirement:
RadTreeView1 . SelectedNode . Node . Value = 7 ;
for set for example:node with value=7 is selected with click button or set this after postback page.
0
Mohamad Javad
Top achievements
Rank 2
Iron
Iron
Iron
answered on 10 Jul 2014, 09:20 AM
In other words, a node can click the Button, I want to get the image, and the style is different from that node by default comes in a blue..
0
Shinu
Top achievements
Rank 2
answered on 11 Jul 2014, 06:00 AM
Hi Mohamad Javad,
I guess you want to select a node in OnClick event of RadButton. Please have a look into the sample code snippet which works fine at my end. Please elaborate your requirement if it doesn't help.
ASPX:
C#:
Thanks,
Shinu.
I guess you want to select a node in OnClick event of RadButton. Please have a look into the sample code snippet which works fine at my end. Please elaborate your requirement if it doesn't help.
ASPX:
<telerik:RadTreeView ID="rtreeDemoList" runat="server"> <Nodes> <telerik:RadTreeNode Text="All" Value="1"> <Nodes> <telerik:RadTreeNode Text="Unread" Value="2"> </telerik:RadTreeNode> <telerik:RadTreeNode Text="Inbox" Value="3"> </telerik:RadTreeNode> <telerik:RadTreeNode Text="Sent Items" Value="4"> </telerik:RadTreeNode> <telerik:RadTreeNode Text="Deleted Items" Value="5"> </telerik:RadTreeNode> <telerik:RadTreeNode Text="Search" Value="6"> </telerik:RadTreeNode> </Nodes> </telerik:RadTreeNode> </Nodes></telerik:RadTreeView><telerik:RadButton ID="rbtnSelectItem" runat="server" Text="Select Node" OnClick="rbtnSelectItem_Click"></telerik:RadButton>C#:
protected void rbtnSelectItem_Click(object sender, EventArgs e){ foreach (RadTreeNode parentNode in rtreeDemoList.Nodes) { foreach (RadTreeNode childNode in parentNode.Nodes) { if (childNode.Value == "6") childNode.Selected = true; } }}Thanks,
Shinu.
0
Mohamad Javad
Top achievements
Rank 2
Iron
Iron
Iron
answered on 11 Jul 2014, 03:36 PM
Shinu.very thanks
​50% of your code solved my problem.
Now I know how I can find which node is Selected when Click the Button?
and Save The value of node,in variable e.g. int variable.
very thanks
​50% of your code solved my problem.
Now I know how I can find which node is Selected when Click the Button?
and Save The value of node,in variable e.g. int variable.
very thanks
0
Shinu
Top achievements
Rank 2
answered on 14 Jul 2014, 10:12 AM
Hi Mohamad Javad,
I guess you want to get the selected node value on the button click. Please have a look into the below C# code snippet to achieve your scenario.
C#:
Please elaborate your requirement if it doesn't help.
Thanks,
Shinu.
I guess you want to get the selected node value on the button click. Please have a look into the below C# code snippet to achieve your scenario.
C#:
protected void rbtnSelectItem_Click(object sender, EventArgs e){ int selectedValue; foreach (RadTreeNode parentNode in rtreeDemoList.Nodes) { if (parentNode.Selected) { selectedValue =Convert.ToInt16(parentNode.Value); break; } foreach (RadTreeNode childNode in parentNode.Nodes) { if (childNode.Selected) { selectedValue = Convert.ToInt16(childNode.Value); break; } } }}Please elaborate your requirement if it doesn't help.
Thanks,
Shinu.