Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > TreeView control issue

Reply
Thread Tools

TreeView control issue

 
 
charles.boyung@gmail.com
Guest
Posts: n/a
 
      06-20-2007
I am trying to use the treeview to display a hierarchy of categories
depending on the top level category chosen from a radiobuttonlist.
However, I am running into a problem where the treeview does not work
correctly (or at least, as expected). When I select a radio button
the first time, it works fine. However, if I select a different radio
button, the tree view does not change to reflect that change - the
original results are still shown. It seems like ASP.Net is caching
that control no matter what I do for as long as the page is alive.

Here is a code sample that can reproduce this issue:

<asp:RadioButtonList runat="Server" ID="rblTest" AutoPostBack="True"
OnSelectedIndexChanged="rblTest_SelectedIndexChang ed">
<asp:ListItem Text="Test0" Value="0" />
<asp:ListItem Text="Test1" Value="1" />
</asp:RadioButtonList>
<asp:TreeView runat="server" ID="tvwTest"
ShowCheckBoxes="All" ShowExpandCollapse="False">
<DataBindings>
<asp:TreeNodeBinding DataMember="Category" TextField="Description"
ValueField="ID" />
</DataBindings>
</asp:TreeView>

protected void rblTest_SelectedIndexChanged(object sender, EventArgs
e)
{
XmlDataSource data = new XmlDataSource();
if (rblTest.SelectedIndex == 0)
{
data.Data = "<Category ID=\"520\" Description=\"Desserts\"><Category
ID=\"709\" Description=\"All Others\" /><Category ID=\"692\"
Description=\"Bars\" /></Category>";
}
else
{
data.Data = "<Category ID=\"520\" Description=\"Desserts2\"><Category
ID=\"709\" Description=\"All Others2\" /><Category ID=\"692\"
Description=\"Bars2\" /></Category>";
}
this.tvwTest.DataSource = data;
this.tvwTest.DataBind();
}

I would greatly appreciate any help with this that anyone can provide.

Thanks,
Charles Boyung

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to access the Page from a TreeNode (treeview 's element) : addinga context menu to a treeview abargaddon ASP .Net Building Controls 0 01-17-2008 11:05 AM
Microsoft Treeview vs System Treeview stepkurt ASP .Net Web Controls 1 09-02-2007 11:32 AM
ASP.NET 2.0 TreeView - Programatically Selecting A TreeView Node =?Utf-8?B?VHltYm93?= ASP .Net 2 01-10-2006 03:51 AM
Issue with a custom TreeView derived from the TreeView control Ionutz ASP .Net Web Controls 2 10-23-2005 03:23 PM
TreeView not rendering nodes? Cacheing of a TreeView Per Salmi ASP .Net Web Controls 1 10-15-2003 01:15 PM



Advertisments