Reloading Treeview From Code Behind

7 posts, 0 answers
  1. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 30 May 2011 Link to this post

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
                            EnablePageHeadUpdate="False">
                            <AjaxSettings>
                                <telerik:AjaxSetting AjaxControlID="lnkbutton">
                                    <UpdatedControls>
                                        <telerik:AjaxUpdatedControl ControlID="RadTreeView1" />
                                    </UpdatedControls>
                                </telerik:AjaxSetting>
                            </AjaxSettings>
                        </telerik:RadAjaxManager>

    lnkbutton is the ID of button which is in RadTreeview1 .
    <telerik:RadTreeNode  Value="pcomment">
                        <NodeTemplate>
                        <telerik:RadTextBox  runat="server" Width="250px" ID="postcomment"></telerik:RadTextBox>
                        <asp:Button Text="Post" runat="server" ID="lnkbutton" onclick="lnkbutton_Click" ></asp:Button>
                        </NodeTemplate>
                        </telerik:RadTreeNode>
    Code - Behind
    protected void RadTreeView1_NodeExpand(object sender, RadTreeNodeEventArgs e)
       {
     
           string getc = "SELECT  [User].Name, [User].ID, Comments.ID AS CID, Comments.Comment, Comments.ItemID, Comments.UID, [User].T28 FROM            [User] INNER JOIN Comments ON [User].ID = Comments.UID WHERE        (Comments.ItemID = 271)";
           dt = dbClass.ReturnDT(getc);
           if (dt.Rows.Count > 0)
           {
                
               int n = dt.Rows.Count;
               for (int m = 0; m < n; m++)
               {
                   RadTreeNode onDemandNode = new RadTreeNode();
                   onDemandNode.ImageUrl = dt.Rows[m]["T28"].ToString();
                   onDemandNode.Text = "<u><b><a href='Profile/profile.aspx?Id="+dt.Rows[m]["ID"].ToString()+"'>"+dt.Rows[m]["Name"].ToString()+"</a></b></u>  "+ dt.Rows[m]["Comment"].ToString();
                    
                   onDemandNode.ExpandMode = TreeNodeExpandMode.ClientSide;
                   //Add the node as a child of the currently expanded node
                   RadTreeView1.Nodes.FindNodeByText("Comments").Nodes.Add(onDemandNode);
               }
                
           }
         }
     protected void lnkbutton_Click(object sender, EventArgs e)
        {
           RadTextBox tb=  (RadTextBox)RadTreeView1.Nodes.FindNodeByValue("pcomment").FindControl("postcomment");
           string insertcomment = " INSERT INTO Comments (ItemID, UID, Comment) VALUES  (271, "+Session["UserId"]+", '"+tb.Text+"')";
           dbClass.DataBase(insertcomment);
          
        }
    What I want is ,whenever the user clicks the button post that is the button with ID lnkbutton , the RadTreeView1 gets refreshed  (without reloading the whole page again) , what should i do to achieve this ??
  2. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 30 May 2011 Link to this post

    Hello Vaibhav,

    Try to change this- AjaxControlID="RadTreeView1"

    If you still have the problem please send us a simle example via support ticket so that we can reseach the problem.

    Kind regards,
    Plamen Zdravkov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 30 May 2011 Link to this post

    I still have the problem , I have not purchased the telerik radcontrols so I am unable to contact the support team ...
    Hope this forum can help me out
  5. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 31 May 2011 Link to this post

    Hello Vaibhav,

    We inspected your code once again and we found no problem.I am sending you a little demo.

    All trial users of Telerik Products can also use our support so if you still have some questions or we misunderstand you somehow please try to change the demo so that we can observe the problem and send it back as a support ticket.

    Kind regards,
    Plamen Zdravkov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 31 May 2011 Link to this post

    Whenever user clicks the button post the datatable which is binding RadTreeView1 gets updated ,that is some more values get inserted in the database , after clicking that button  i want to refresh that treeview so that new entries are also seen .
    I do not want to refresh a Label but the treeview and the demo code u provided refreshes a Label ,
    I hope u get what i want to achieve ,
    Vaibhav
  7. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 02 Jun 2011 Link to this post

    Hi Vaibhav,

    Can you try setting your DataSource and calling DataBind again for RadTreeView on the button click event?
    protected void lnkbutton_Click(object sender, EventArgs e)
       {
            
           RadTextBox b = RadTreeView1.FindNodeByValue("pcomment").FindControl("postcomment") as RadTextBox;
           b.Text =DateTime.Now.ToString();
           RadTreeView1.DataSource = yourdatasource;
           RadTreeView1.DataBind();
             
       }

    Does this help?

    Regards,
    Plamen Zdravkov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  8. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 02 Jul 2011 Link to this post

    Thanks , that did the needful .. :)
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017