Welcome Guest Search | Active Topics | Sign In | Register

treeview databind XmlDataSource Options
MartinW
Posted: Friday, April 3, 2009 1:38:39 PM
Rank: Newbie
Groups: Member

Joined: 7/26/2008
Posts: 6
I'm attempting to set CheckState of a treeview by binding to an XmlDataSource that is initialised with an xml string. I've tried setting the treeview node xmlTextWriter.WriteAttributeString("checkstate", "Checked") and xmlTextWriter.WriteAttributeString("checkstate", "1") with no success. The treeview displays as a single checkbox receeded by 4 dots.

Here's the aspx fragment
[code=htm]
<TopGroup>
<Bindings>
<eo:DataBinding DataField="@value" Property="Value" />
<eo:DataBinding DataField="@checkstate" Property="CheckState" />
<eo:DataBinding DataField="@title" Property="PageViewID" />
</Bindings>
</TopGroup>
eo_support
Posted: Friday, April 3, 2009 4:01:45 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Your code is correct. The XML file should be "Checked" instead of "1". You can try to set the TreeView's XmlFile property directly and see if it works for you. If it does, then check if you have set the XmlDataSource's XPath property. Binding to XmlFile and XmlDataSource are almost identical, except for binding to XmlFile skips the root, while XmlDataSource by default starts from the root.

Consider the following XML file:

Code: XML
<root title="root" checkstate="Unchecked">
    <node title="child 1" checkstate="Checked" />
    <node title="child 2" checkstate="Checked" />
</root>


If you do not set XmlDataSource's XPath property, you will get a single top level tree node "root" with two child nodes "child 1" and "child 2". However if you set XPath property to "/root/*", you will get a two top level tree nodes "child 1" and "child 2".

Please let us know if this resolves the issue.

Thanks!
MartinW
Posted: Saturday, April 4, 2009 3:18:22 AM
Rank: Newbie
Groups: Member

Joined: 7/26/2008
Posts: 6
Thanks for the prompt reply. Looks like checkstate must be defined for all nodes in the XML. I was only specifying checkstate for checked nodes. Now all working.
eo_support
Posted: Saturday, April 4, 2009 8:06:49 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Thanks for the update. Yes. It indeed requires checkstate to be specified on all nodes.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.