Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET4.0
This is my code, but when I expand the node data is not displaying, but every thing is working fine. What is the problem, in which event I should write?
protected void TreeView1_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
   {
       Response.Write(e.Node.Text + "-" + e.Node.Value);
       DataSet dsAllYearEventIDs = obj.GetCompanyID(e.Node.Text);
 
       DataTable dt1 = dsAllYearEventIDs.Tables[0];
       TreeNode year = (TreeNode)TreeView1.FindNode("year");
       year = new TreeNode();
       year.PopulateOnDemand = true;
 
       TreeNode yearchild = new TreeNode();
       yearchild.PopulateOnDemand = true;
       yearchild.SelectAction = TreeNodeSelectAction.None;
       yearchild.Text = "<u style='text-style:italic;'>" + "Clinical Events with current guidance of year " + e.Node.Text + "</u>";
 
       year.ChildNodes.Add(yearchild);
       StringBuilder sbyear = new StringBuilder();
       sbyear.AppendLine("<table style='border:1px solid gray;' width='100%'>");
       for (int j = 0; j < dt1.Rows.Count; j++)
       {
           DataSet dsAllDescription = obj.GetTickerEventDescription(dt1.Rows[j]["Company_ID"].ToString());
           DataTable dt2 = new DataTable();
           dt2 = dsAllDescription.Tables[0];
 
           sbyear.AppendLine("<tr>");
           sbyear.AppendLine("<td style='width:120px; border:0px dotted gray;'>");
           sbyear.AppendLine("<a href='" + "Ticker.aspx?tick=" + dt2.Rows[0][0].ToString() + "'><b>" + dt2.Rows[0][0].ToString() + "</b></a>");
           sbyear.AppendLine("</td>");
           sbyear.AppendLine("<td style='width:120px; border:0px dotted gray;'>");
           sbyear.AppendLine(dt2.Rows[0][1].ToString());
           sbyear.AppendLine("</td>");
           sbyear.AppendLine("<td style='width:180px; border:0px dotted gray;'>");
           sbyear.AppendLine(dt2.Rows[0][2].ToString());
           sbyear.AppendLine("</td>");
           sbyear.AppendLine("</tr>");
       }
       sbyear.AppendLine("</table>");
       TreeNode childnode = new TreeNode();
       childnode.PopulateOnDemand = true;
       childnode.SelectAction = TreeNodeSelectAction.None;
       childnode.Text = sbyear.ToString();
       year.ChildNodes.Add(childnode);
   }
 
I have tried by this event also
protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e)
    {
        DataSet dsAllYearEventIDs = obj.GetCompanyID(e.Node.Text);
 
        DataTable dt1 = dsAllYearEventIDs.Tables[0];
        TreeNode year = (TreeNode)TreeView1.FindNode("year");
        year = new TreeNode();
         year.PopulateOnDemand = false;
        TreeNode yearchild = new TreeNode();
          yearchild.PopulateOnDemand = false;
        yearchild.SelectAction = TreeNodeSelectAction.None;
        yearchild.Text = "<u style='text-style:italic;'>" + "Clinical Events with current guidance of year " + e.Node.Text + "</u>";
 
        year.ChildNodes.Add(yearchild);
        StringBuilder sbyear = new StringBuilder();
        sbyear.AppendLine("<table style='border:1px solid gray;' width='100%'>");
        for (int j = 0; j < dt1.Rows.Count; j++)
        {
            DataSet dsAllDescription = obj.GetTickerEventDescription(dt1.Rows[j]["Company_ID"].ToString());
            DataTable dt2 = new DataTable();
            dt2 = dsAllDescription.Tables[0];
 
            sbyear.AppendLine("<tr>");
            sbyear.AppendLine("<td style='width:120px; border:0px dotted gray;'>");
            sbyear.AppendLine("<a href='" + "Ticker.aspx?tick=" + dt2.Rows[0][0].ToString() + "'><b>" + dt2.Rows[0][0].ToString() + "</b></a>");
            sbyear.AppendLine("</td>");
            sbyear.AppendLine("<td style='width:120px; border:0px dotted gray;'>");
            sbyear.AppendLine(dt2.Rows[0][1].ToString());
            sbyear.AppendLine("</td>");
            sbyear.AppendLine("<td style='width:180px; border:0px dotted gray;'>");
            sbyear.AppendLine(dt2.Rows[0][2].ToString());
            sbyear.AppendLine("</td>");
            sbyear.AppendLine("</tr>");
        }
        sbyear.AppendLine("</table>");
        TreeNode childnode = new TreeNode();
        childnode.PopulateOnDemand = false;
        childnode.SelectAction = TreeNodeSelectAction.None;
        childnode.Text = sbyear.ToString();
        year.ChildNodes.Add(childnode);
    }
To make it work what change I should do in the above code?
 
PageLoad Code::
EventManager obj = new EventManager();
    DataSet ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {         
            TreeView1.CollapseAll();           
        }
    }
Posted 14-Jan-13 23:25pm
Edited 14-Jan-13 23:44pm
105.4K
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 560
1 OriginalGriff 325
2 CPallini 280
3 ChauhanAjay 149
4 BillWoodruff 130
0 OriginalGriff 6,474
1 Sergey Alexandrovich Kryukov 6,190
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100