Welcome Guest Search | Active Topics | Sign In | Register

(un)checking treeview during databind... Options
Christiano
Posted: Wednesday, December 17, 2008 10:50:29 AM
Rank: Advanced Member
Groups: Member

Joined: 11/12/2008
Posts: 42
Hey there...

Once again, i'm having problems with databinding...

i'm binding from a SQL server. Some nodes must be checked and some dont.
Who rules it is the MenuStat field.


My whole binding code:

Code: Visual Basic.NET
da.Fill(ds2, "Menus")

            Dim r As DataRelation = ds2.Relations.Add(ds2.Tables("Menus").Columns("MenuCodi"), ds2.Tables("Menus").Columns("MenuPaiX"))
            r.Nested = True

            binding = New DataBinding
            binding.DataField = "MenuDesc"
            binding.Property = "Text-Html"
            tvMenus.Bindings.Add(binding)

            binding = New DataBinding
            binding.DataField = "MenuCodi"
            binding.Property = "ItemID"
            tvMenus.Bindings.Add(binding)


            binding = New DataBinding
            binding.DataField = "MenuStat"
            binding.Property = "Checked"
            tvMenus.Bindings.Add(binding)

            tvMenus.DataSource = ds2
            tvMenus.DataBind()



Tried changing the property to CheckState, but all fields got checked.
MenuStat tried True/False, 1/0, Checked/Unchecked


How can I do this???
Don't want to bind it with datareader, item by item...


tks...

eo_support
Posted: Wednesday, December 17, 2008 11:41:29 AM
Rank: Administration
Groups: Administration

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

True/False should work. You will need to make sure the data type for your DataColumn is "Boolean" or "String". When the data type is "String", you can also use "1" for checked, any other value is considered unchecked.

Thanks!
Christiano
Posted: Wednesday, December 17, 2008 11:55:29 AM
Rank: Advanced Member
Groups: Member

Joined: 11/12/2008
Posts: 42
right... should i use CheckState or Checked?
eo_support
Posted: Wednesday, December 17, 2008 12:01:35 PM
Rank: Administration
Groups: Administration

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

MenuItem has Checked. TreeNode has CheckState. If you use TreeView, then you should use CheckState.

For CheckState the data type can be string or integer. When using string value, you must use "Unchecked", "Checked" or "Interminate"; when using int value, it must be 0, 1, or 2.

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.