TreeView control issue

Discussion in 'ASP .Net Web Controls' started by charles.boyung@gmail.com, Jun 20, 2007.

  1. Guest

    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_SelectedIndexChanged">
    <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
     
    , Jun 20, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VHltYm93?=
    Replies:
    2
    Views:
    24,475
    =?Utf-8?B?VHltYm93?=
    Jan 10, 2006
  2. abargaddon
    Replies:
    0
    Views:
    1,067
    abargaddon
    Jan 17, 2008
  3. Per Salmi

    TreeView not rendering nodes? Cacheing of a TreeView

    Per Salmi, Oct 15, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    474
    Steve Drake
    Oct 15, 2003
  4. Ionutz
    Replies:
    2
    Views:
    534
    Ionutz
    Oct 23, 2005
  5. stepkurt

    Microsoft Treeview vs System Treeview

    stepkurt, Aug 29, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    385
    Teemu Keiski
    Sep 2, 2007
Loading...

Share This Page