Welcome Guest Search | Active Topics | Sign In | Register

Tree View Data Value Options
Posted: Wednesday, October 7, 2009 7:03:16 PM
Rank: Newbie
Groups: Member

Joined: 9/17/2009
Posts: 3
Dear Friends,

How do I set a value for each of the tree view nodes when binding a data table, what I am trying to achieve is to be able to pre-populate every check box in the tree view as checked or not checked based on info from my db. Then, let the user change the checked nodes and update the data base upon the values of the checked nodes.

Regards,
R
eo_support
Posted: Wednesday, October 7, 2009 7:42:46 PM
Rank: Administration
Groups: Administration

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

Populating the TreeView from your DB is easy. Please see here for more details:

http://doc.essentialobjects.com/library/1/menucommon/databinding/databinding_overview.aspx

In order to update DB based when the check state change, you will need to handle this event:

http://doc.essentialobjects.com/library/1/eo.web.treeview.itemcheckstatechanged.aspx

Hope this helps.

Thanks
Posted: Wednesday, October 7, 2009 8:49:49 PM
Rank: Newbie
Groups: Member

Joined: 9/17/2009
Posts: 3
Thanks, But I don't want to handle events from the treeview, I need to do the next two things:

1. When I said "pre-populate" I meant to be able to read from my Data Base what checkboxes were checked before by the user, and when binding the tree view, to be able to check those check boxes automatically. When I bind the tree view from a DataTable, is there a way to set the value property of the node?

2. What I need is to iterate through all the treeview nodes and see which checked boxes are checked, once I know this, I want to retrieve their values in order to be able to change a flag in my Data Base. All this has to be done when the user presses an asp button, and no every time he checks the checkbox.
eo_support
Posted: Wednesday, October 7, 2009 9:06:26 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Rodrigo wrote:
1. When I said "pre-populate" I meant to be able to read from my Data Base what checkboxes were checked before by the user, and when binding the tree view, to be able to check those check boxes automatically. When I bind the tree view from a DataTable, is there a way to set the value property of the node?

This is exactly what data binding does. Data binding allows you to populate the TreeView and then check the checkboxes automatically based on your data source. Please take a look of the documentation first.


Rodrigo wrote:
2. What I need is to iterate through all the treeview nodes and see which checked boxes are checked, once I know this, I want to retrieve their values in order to be able to change a flag in my Data Base. All this has to be done when the user presses an asp button, and no every time he checks the checkbox.

ItemCheckStateChanged is the correct solution. The event is NOT fired when you check the checkbox. It is fired when your page posts back (when user presses a button). What this event does is to help you to identify which node has been changed. Consider the following scenario:

1. You have 10 records, with 6 of them checked;
2. You populate the TreeView from your DB, 6 tree nodes are automatically checked based on data in your db;
3. User checked another 2 nodes. So now 8 nodes are checked;
4. User clicks a button to submit the changes;

Now you have two options:

1. Iterate through all 10 nodes (you can do this with recursive code easily) and check each nodes' Checked property and update your DB 10 times;
-- OR --
2. Handle ItemCheckStateChanged event. This event is fired for each treenode whose check state has been changed. Because in this case only 2 nodes has changed, so this event will be fired two times. As a result, you will update your DB only twice;

Obviously option 2 is much better because it only updates what has been changed.

Hope this clears up.

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.