Welcome Guest Search | Active Topics | Sign In | Register

Treeview: Databinding with images Options
Christiano
Posted: Thursday, December 11, 2008 12:22:20 PM
Rank: Advanced Member
Groups: Member

Joined: 11/12/2008
Posts: 42
Hi...

I'm populating a treeview from a relational, nested dataset.

But I would like to place an image (reds, yellows or green dots .gif) on the side of each item from Level 1, indication whether they are active, inactive or waiting.

is it possible with DataBind or I have to do nested loops???

tks in advance,
Christiano.
eo_support
Posted: Thursday, December 11, 2008 6:58:25 PM
Rank: Administration
Groups: Administration

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

I believe you can do that with DataBinding object. A DataBinding object maps a data field to a menu item property. You can find more information on DataBinding object at here:

http://www.essentialobjects.com/ViewDoc.aspx?t=MenuCommon%2fDataBinding%2fpopulate_table.html

Thanks!
Saed
Posted: Friday, December 12, 2008 2:38:11 AM
Rank: Advanced Member
Groups: Member

Joined: 10/15/2008
Posts: 45
If I got you right, you want to change displayed Node image depending on Node status: Active, Inactive or Wait.

you can achieve that in different ways, but the simplest approach that crossed my mind at moment is the following:

1) Store the status as Node's Value, something like:
Code: Visual Basic.NET
myNode.Value = "Active"


2) Check Node status and set Node's ImageUrl property accordingly.
Here, you might need a conditional loop or Case block to iterate through status possible values.

To set Node's ImageUrl, do something like:
Code: Visual Basic.NET
myNode.ImageUrl = "green.gif"


I will leave iteration code to you to attempt.


Hope this helps.

Regards,

Saed Hamdan
"Man may be destroyed but not defeated" -Hemmingway
eo_support
Posted: Friday, December 12, 2008 5:41:54 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi Saed, thank you very much for providing additional information!
Christiano
Posted: Friday, December 12, 2008 5:59:12 AM
Rank: Advanced Member
Groups: Member

Joined: 11/12/2008
Posts: 42
Tks a lot both for the help...

Finally I've figured out how to do this...

Added a binding control to the treeview with this code:
Code: Visual Basic.NET
binding = New DataBinding
binding.DataField = "StatImag"
binding.Property = "ImageUrl"
tvModelos.Bindings.Add(binding)


And it worked out as should.

the only thing, is that i must get the full path from the database. But that's no big deal...
eo_support
Posted: Friday, December 12, 2008 6:33:32 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Great. Thanks for the update!


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.