tag:blogger.com,1999:blog-12419046.post114596888293586157..comments2023-09-09T06:35:12.217-07:00Comments on Lakshmi's Tech Doodles: ASP.NET : Binding XML Data to TreeView with Checked state of CheckboxesLakshmihttp://www.blogger.com/profile/05033914754047255171noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-12419046.post-41555191927697935712009-11-06T08:08:41.343-08:002009-11-06T08:08:41.343-08:00Greetings,
I found your post to be extremely help...Greetings,<br /><br />I found your post to be extremely helpful. I had also found a way to enhance your solution. Instead of piggy-backing your value in the Target field and then disabling the SelectAction, you can just keep your extra values in the XML and read them directly.<br /><br />Here's a portion of the XML that I am reading:<br /><br /> [trenode TextField="Accounting" ValueField="/My Reports/Accounting" ImageUrlField="~/Images/16fold.gif" CollapseTree="0"]<br /> [trenode TextField="Permissions" ValueField="Permissions" ImageURLField="" CheckFalue="false" CollapseTree="1"]<br /> [/trenode]<br /><br /><br />The XML values that I care about are CheckValue and CollapseTree.<br /><br />I had changed the TreeNodeDataBound event to:<br /><br /> protected void tvwReports_TreeNodeDataBound(object sender, TreeNodeEventArgs e)<br /> {<br /> String CheckValue;<br /> String CollapseTree;<br /><br /> try<br /> {<br /> CheckValue = ((XmlElement)e.Node.DataItem).Attributes.GetNamedItem("CheckValue").Value;<br /> }<br /> catch<br /> {<br /> CheckValue = "false";<br /> }<br /> try<br /> {<br /> CollapseTree = ((XmlElement)e.Node.DataItem).Attributes.GetNamedItem("CollapseTree").Value;<br /> }<br /> catch<br /> {<br /> CollapseTree = "0";<br /> }<br /> <br /> if (CheckValue == "true") //(e.Node.Target == Convert.ToString("true"))<br /> {<br /> e.Node.Checked = true;<br /> }<br /> else<br /> {<br /> e.Node.Checked = false;<br /> }<br /> if (CollapseTree == "1")<br /> {<br /> e.Node.Collapse();<br /> }<br /> else<br /> {<br /> e.Node.Expand();<br /> }<br /><br /> }<br /><br />I had also removed the "TargetField", "SelectAction" and the "PopulateOnDemand" options from the TreeNodeBinding section. They were not needed anymore since I was reading the values directly.<br /><br />Thank you for your time.<br /><br />Terry.Unknownhttps://www.blogger.com/profile/11266601244114497715noreply@blogger.comtag:blogger.com,1999:blog-12419046.post-83937714783321988062007-09-27T08:47:00.000-07:002007-09-27T08:47:00.000-07:00Ok now I see how the TreeVIew has a DataBindings e...Ok now I see how the TreeVIew has a DataBindings element, how would you do this with a DataList or a Repeater since it does not have a DataBindings element?<BR/><BR/>I want to bind the XPath and XPathSelect results from the XmlDataSource to my controls in my ItemTemplate.. is this possible?dgenhttps://www.blogger.com/profile/05336599620099353425noreply@blogger.comtag:blogger.com,1999:blog-12419046.post-88176410815281269572007-07-13T06:48:00.000-07:002007-07-13T06:48:00.000-07:00Hi..Great article .It solved my problem. Actually ...Hi..<BR/>Great article .It solved my problem. Actually i was getting a problem when using XMLDataource with TreeView control.It always displays the root node of the xml.But using the Xpath the problem was solved.<BR/><BR/>Thanks again.It's really very very nice articleUnknownhttps://www.blogger.com/profile/16406077971250015999noreply@blogger.comtag:blogger.com,1999:blog-12419046.post-1147580762429640492006-05-13T21:26:00.000-07:002006-05-13T21:26:00.000-07:00This comment has been removed by a blog administrator.Vikas Gadduhttps://www.blogger.com/profile/11712556748971188468noreply@blogger.comtag:blogger.com,1999:blog-12419046.post-1147662043203491002006-05-14T20:00:00.000-07:002006-05-14T20:00:00.000-07:00This is the only comment here that's not spam.The ...This is the only comment here that's not spam.<BR/><BR/>The article was cool, by the way.<BR/><BR/>(notice I'm not promoting any fishy offers)Daquellhttps://www.blogger.com/profile/09657299848855834693noreply@blogger.com