Welcome Guest Search | Active Topics | Sign In | Register

TreeView Control Options
Paulo Mondragon
Posted: Monday, November 3, 2008 10:16:10 AM
Rank: Advanced Member
Groups: Member

Joined: 6/4/2008
Posts: 38
Hello,

I'm using a ListBox object to load the checked items in my TreeView object, but it only loads

EO.Web.TreeNode
EO.Web.TreeNode
EO.Web.TreeNode


for each node I get checked. The sintaxis I'm using is:

With ListBox1
.DataSource = trMenus.GetCheckedNodes()
'''.DataTextField = "Description"
'''.DataValueField = "Id"
.DataBind()
End With

I want to load the ID of the selected item, I don't know where tu use the Value property you refer. Can you help me with this ?
Thanks a lot.
eo_support
Posted: Monday, November 3, 2008 10:34:41 AM
Rank: Administration
Groups: Administration

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

I don't think you can use DataTextField or DataValueField with an array of TreeNodes. The reason is very simple, "Description" and "ID" are properties, they are not "Field". If you were populating from a DB table, then you would have field.

The most basic way of adding ListBox item would be something like this:

Code: C#
LisItem item = new ListItem("something");
ListBox1.Items.Add(item);


Since populating/data binding a list box is a generic ASP.NET topic, if you have any more question on this, you will need to seek other resource. Our TreeView/TreeNode does not provide any additional support on this rather than being as plain .NET objects as to this matter.

Thanks!
Paulo Mondragon
Posted: Monday, November 3, 2008 10:45:15 AM
Rank: Advanced Member
Groups: Member

Joined: 6/4/2008
Posts: 38
I made a wrong question.

I want to get the Id or Text or something of the node I got checked. I read in the support to use the GetCheckedNodes property, but I don't understand how tu use it.
In the last post, I use the ListBox control like an example only to get this value.

Hope you can help me.

Again, thanks a lot.
eo_support
Posted: Monday, November 3, 2008 10:56:32 AM
Rank: Administration
Groups: Administration

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

The data flow in your scenario mostly to be something like this:

"Description" (your data source) -> TreeNode -> ListBox (or whatever else)

This is a two step process. For the first step, you would need to go over the TreeView data binding section in the documentation. Basically, you can "store" a number of values into each TreeNode. For example, you may choose to "store" "Description" in the TreeNode's Text property (which get shown to the user), while also store "ID" in the TreeNode's Value property (which does not get shown in anyway).

Once you have that step done, you can use those values you stored there. For example, if you have previous stored the "ID" property in the TreeNode's Value property, you would be able to get it back this way:

string id = treeNode.Value;

Or in case of selected node:

string id = trMenus.GetCheckedNodes()[0].Value;

Hope this clears up.

Thanks
Paulo Mondragon
Posted: Monday, November 3, 2008 11:30:23 AM
Rank: Advanced Member
Groups: Member

Joined: 6/4/2008
Posts: 38
I'm using this sintaxis to load my TreeView, the same I use to load my Menu control :

strSQL = "Execute " & strDB & "..sp_CargaMenus " & intRequestUsuarioId & ", " & intRequestUsuarioPermisos & ", '" & strValueRequest & "'"
trMenus.DataSource = CargaMenus(strSQL)
trMenus.DataFields = "cNivel01|cNivel02|cNivel03|cNivel04|cNivel05"
trMenus.TargetWindow = "fmeDisplay"
objBinding.DataField = "IdMenu"
objBinding.Property = "NavigateUrl"
trMenus.Bindings.Add(objBinding)
trMenus.DataBind()


In my TreeView I replace the property "NavigateUrl" for "Value", I don't know if is correct.

I tried to use the sintaxis you propose trMenus.GetCheckedNodes()[0].Value, but the only property allowed is trMenus.GetCheckedNodes.GetValue(SOME VALUE), and I can't get the value of the checked item in the tree view.

Can you send me more information please ?

Thanks a lot



eo_support
Posted: Monday, November 3, 2008 11:40:03 AM
Rank: Administration
Groups: Administration

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

Your data binding code is fine. As to GetCheckedNodes, you may want to ask somebody else around you to show you what to do. I believe you are somewhere trapped by some basic .NET syntax. GetCheckedNodes returns an array of TreeNode objects (the code we give to you is in C#, so you will want to change that to VB). You would simply use it as an array like you use any other arrays. So we don't really have any more "information" to tell you on this regard.

You may also want to check the reference section in the documentation. Everything we tell you here so far is covered there.

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.