This is a migrated thread and some comments may be shown as answers.
Reloading Treeview From Code Behind
6 Answers 36 Views
This is a migrated thread and some comments may be shown as answers.
dotnetrockerzzz
Top achievements
Rank 2
dotnetrockerzzz asked on 30 May 2011, 06:57 AM
<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 ??

6 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 30 May 2011, 12:42 PM
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.

0
dotnetrockerzzz
Top achievements
Rank 2
answered on 30 May 2011, 01:40 PM
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
0
Plamen
Telerik team
answered on 31 May 2011, 01:26 PM
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.

0
dotnetrockerzzz
Top achievements
Rank 2
answered on 31 May 2011, 06:14 PM
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
0
Plamen
Telerik team
answered on 02 Jun 2011, 03:25 PM
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.

0
dotnetrockerzzz
Top achievements
Rank 2
answered on 02 Jul 2011, 08:05 AM
Thanks , that did the needful .. :)
Asked by
dotnetrockerzzz
Top achievements
Rank 2
Answers by
Plamen
Telerik team
dotnetrockerzzz
Top achievements
Rank 2
Share this question
or