Welcome Guest Search | Active Topics | Sign In | Register

Databinding to a treenode's checked property Options
Ben Switzer
Posted: Wednesday, July 25, 2007 9:21:38 AM
Rank: Advanced Member
Groups: Member

Joined: 5/30/2007
Posts: 30
I am trying to display my treeview with the checkboxes that have been checked/unchecked from last visit (stored in the database as true/false). I tried to add the following binding but it is not working.

<eo:DataBinding DataField="RequiredList" Property="Checked" />

Any ideas?

Thanks
eo_support
Posted: Wednesday, July 25, 2007 9:24:01 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi Ben,

Thanks for posting your question here. We will look into it and get back to you as soon as possible.

Thanks
eo_support
Posted: Wednesday, July 25, 2007 11:45:58 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi Ben,

We looked into it and noticed that TreeNode can bind to CheckState property, but not Checked property. So try to change Checked to CheckState should work. The data type can be boolean or integer.

Thanks
Ben Switzer
Posted: Wednesday, July 25, 2007 12:06:36 PM
Rank: Advanced Member
Groups: Member

Joined: 5/30/2007
Posts: 30
I am getting the following error:

Data binding failed on property CheckState. Specified cast is not valid

The value of True is whats coming from the database.
eo_support
Posted: Wednesday, July 25, 2007 12:19:36 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi Ben,

I apologize, CheckState takes integer or string, not integer or boolean. When the value is a string, it recognizes "Checked", "Unchecked" and "Indeterminate", when the value is an integer, it recognizes 0, 1 and 2. Even though I think it would make perfect sense to also support boolean.

Thanks
Ben Switzer
Posted: Wednesday, July 25, 2007 12:28:30 PM
Rank: Advanced Member
Groups: Member

Joined: 5/30/2007
Posts: 30
Is it possible to bind the checkstate to a public function returns a valid string based on the bool value?
eo_support
Posted: Wednesday, July 25, 2007 12:32:32 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi Ben,

No. But you can handle ItemDataBound event to achieve the same result. Inside ItemDataBound event you will be able to modify the newly data bound tree node based on your data item (access the current data item by "TreeView1.DataItem", which returns an object whose type depends on your data source).

Thanks
Ben Switzer
Posted: Thursday, July 26, 2007 10:08:32 AM
Rank: Advanced Member
Groups: Member

Joined: 5/30/2007
Posts: 30
I am still getting the error before ItemDatabound is fired. I verified this debugging.
eo_support
Posted: Thursday, July 26, 2007 10:49:06 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi Ben,

When you use ItemDataBound, you do not use DataBinding object to map the field at all. You set the property by code based on your data source.

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.