I use RadTreeView
in my master page :
but i face the following problem :
I lose my selections when i click on the nodes of the tree view .and every time i click on the node it makes (Response.Redirect("..."))
which make the master entering the (!Page.IsPostback)
every time and bind the tree view again so i lose my selections .
How to fix this problem .
My .aspx :
<telerik:RadTreeView ID="rtv_cm" runat="server" OnNodeExpand="rtv_cm_NodeExpand"
OnNodeClick="rtv_cm_NodeClick" Skin="WebBlue">
</telerik:RadTreeView>
My .cs :
protected void Page_Load(object sender, EventArgs e)
{
if (Session["emp_num"] != null && !string.IsNullOrEmpty(Session["emp_num"].ToString()))
{
if (!Page.IsPostBack)
{
LoadRootNodes(rtv_cm, TreeNodeExpandMode.ServerSide);
}
}
else
{
Response.Redirect("Frm_login.aspx");
}
}
protected void rtv_cm_NodeClick(object sender, RadTreeNodeEventArgs e)
{
dt_childs = (DataTable)Session["dt_childs"];
IEnumerable<DataRow> result = from myRow in dt_childs.AsEnumerable()
where myRow.Field<string>("task_id").TrimEnd() == e.Node.Value.TrimEnd()
select myRow;
if (result != null)
{
if (!string.IsNullOrEmpty(result.ElementAtOrDefault(0).Field<string>("page_name")))
{
Response.Redirect(result.ElementAtOrDefault(0).Field<string>("page_name").TrimEnd(), false);
}
}
}
How I get The menu :
private void LoadRootNodes(RadTreeView treeView, TreeNodeExpandMode expandMode)
{
dt = Menu_db.GetMenu(Session["emp_num"].ToString(), CMSession.Current.db_code);
IEnumerable<DataRow> result = from myRow in dt.AsEnumerable()
where myRow.Field<string>("task_id").TrimEnd() == "0"
select myRow;
if (result != null && result.Count()>0)
{
DataTable dt_roots = result.CopyToDataTable<DataRow>();
Session["dt"] = dt;
Session["dt_roots"] = dt_roots;
foreach (DataRow row in dt_roots.Rows)
{
RadTreeNode node = new RadTreeNode();
node.Text = row["task_name"].ToString().TrimEnd();
node.Value = row["task_id"].ToString().TrimEnd();
if (Convert.ToInt32(row["count"]) > 0)
{
node.ExpandMode = expandMode;
}
treeView.Nodes.Add(node);
}
}
}