protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["pageid"] != null)
{
ViewState["pageid"] = Request.QueryString["pageid"].ToString();
}
TreeBind(null, 0);
}
}
private void TreeBind(RadTreeNode n, int PageId)
{
DataSet ObjdsPage = (DataSet)ObjLogic.DisplayPagesByPrntIdnew(PageId);
if (ObjdsPage.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ObjdsPage.Tables[0].Rows.Count; i++)
{
RadTreeNode node = new RadTreeNode(ObjdsPage.Tables[0].Rows[i][0].ToString(), ObjdsPage.Tables[0].Rows[i][1].ToString());
TreeBind(node, Convert.ToInt32(ObjdsPage.Tables[0].Rows[i][1].ToString()));
if (n == null)
{
radtreepage.Nodes.Add(node);
}
else
{
n.Nodes.Add(node);
}
}
}
}
protected void radtreepage_NodeClick(object o, RadTreeNodeEventArgs e)
{
//int flag = 1;
if (radtreepage.SelectedNode.Value != "0")
{
Session["Value"] = radtreepage.SelectedNode.Value.ToString();
Session["NodeText"] = radtreepage.SelectedNode.Text.ToString();
}
radtreepage.SelectedNode.Selected = false;
}
protected void radtreepage_NodeCheck(object o, RadTreeNodeEventArgs e)
{
if (ViewState["pageid"] != null)
{
pageId = Convert.ToInt32(ViewState["pageid"].ToString());
}
else
{
pageId = -2;
}
int PageParentValue =Convert.ToInt32(e.NodeChecked.Value);
string NodeText = e.NodeChecked.Text;
bool PageCheck = e.NodeChecked.Checked;
if (PageCheck == true)
{
relation = -1;
//insert Relation
ObjLogic.InsertUpdatePagesRelation(pageId, PageParentValue, relation);
}
else if (PageCheck == false)
{
relation = 0;
//delete Relation
ObjLogic.InsertUpdatePagesRelation(pageId, PageParentValue, relation);
}
// Response.Redirect("View.aspx?pagename="+NodeText);
//frm_control.Attributes["src"] = "View.aspx?pagename=" + NodeText;
}
No comments:
Post a Comment