Hi again,
After doing what Amanda suggested, the next step was to wrap my TreeView control with an Ajax UpdatePanel in order to do Asynchronous postbacks and refresh only the Treview control, it was then when I realized that with Ajax I didn't need the Amanda's postBackByObject approach anymore, I just attached a trigger from the UpdatePanel to a hidden button and that's it!, the button will do the Postback. See the code below:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TreeView ID="TreeViewMenu" runat="server" DataSourceID="XmlDataSourceMenu" ShowCheckBoxes="All" BorderWidth="3px" BorderColor="White" NodeStyle-ForeColor="#5982A2" OnTreeNodeDataBound="TreeViewMenu_TreeNodeDataBound" OnPreRender="TreeViewMenu_PreRender" OnTreeNodeCheckChanged="TreeViewMenu_TreeNodeCheckChanged">
<DataBindings>
<asp:TreeNodeBinding DataMember="Menu" TextField="Name" Depth="0" SelectAction="None" ValueField="Id" />
<asp:TreeNodeBinding DataMember="Submenu" TextField="Name" Depth="1" SelectAction="None" ValueField="Id" />
</DataBindings>
<NodeStyle ForeColor="#5982A2" />
</asp:TreeView>
<asp:XmlDataSource ID="XmlDataSourceMenu" runat="server" DataFile="~/_resources/Menu.xml" XPath="//Menu" TransformFile="~/_resources/Menu.xslt">
</asp:XmlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="buttonCheck" EventName="click" />
</Triggers>
</asp:UpdatePanel>
<asp:button ID="buttonCheck" runat="server" CausesValidation="false" />
and the code behind is:
buttonCheck.Attributes.CssStyle["visibility"] = "hidden";
TreeViewMenu.Attributes.Add("onclick", string.Format("document.getElementById('{0}').click();", buttonCheck.ClientID));
Of course there is no need to say that you must have an ScriptManager control for Ajax to work.
Patrick.