Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
Data Binding Code Behind
posted

Hello,

I have a WebDataTree that is bound to a XmlDataSource. I set XmlDataSource.Data at runtime in Page_Init and everything is OK. I have a Button that do Postback, make some changes to the xml data, set XmlDataSource.Data = new_xml_data and tries to rebind the tree. But when the page is shown the Tree contains the old xml. XmlDataSource is with EnableCaching="false" EnableViewState="false" and WebDataTree is with iewStateMode="Disabled".

Here is sample code:

<ig:WebDataTree ID="WebDataTree1" runat="server" Height="300px" Width="200px" 
        ViewStateMode="Disabled" InitialExpandDepth="10"  NodeIndent="10" 
        DataSourceID="xmlDsTree">
    </ig:WebDataTree>
    <asp:XmlDataSource ID="xmlDsTree" runat="server" EnableCaching="false" EnableViewState="false" ></asp:XmlDataSource>
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />


        string Xml
        {
            get { return (string)Session["Xml"]; }
            set { Session["Xml"] = value; }
        }

        protected void Page_Init(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Xml = "<a><b></b></a>";
            }
            xmlDsTree.Data = Xml;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Xml = "<a><b><c></c></b></a>";
            xmlDsTree.Data = Xml;
            WebDataTree1.DataBind();
        }