Welcome Guest Search | Active Topics | Sign In | Register

TreeView Problems Options
A. Hert
Posted: Friday, September 26, 2008 1:29:51 AM
Rank: Newbie
Groups: Member

Joined: 9/26/2008
Posts: 1
Hello

I am having three major problems with the TreeView control:

1. All AutoCheck-Properties don't work. For example, when the user checks a parent node, its child nodes won't be checked automatically, and vice versa.

2. When checking or unchecking a node, no postback is sent, even with RaisesServerEvent="true"

3. When the page ist posted back via a submit button, it is not possible in the code behind to iterate through the tree's nodes and determine which nodes have been checked by the user (using the Checked-Property of each node).

Here's my code:

Code: HTML/ASPX
<EO:TreeView runat="server" ID="trvRechte" AllowMultiSelect="true" AutoCheckChildren="true"
	AutoCheckParent="true" AutoUncheckChildren="true" EnableScrolling="true" RaisesServerEvent="true" OnItemCheckStateChanged="trvRechte_CheckStateChanged" >
	<TopGroup>
		<TemplateItem>
			<CustomItem>
				<asp:CheckBox CssClass="normal" runat="server" Text='<%#Eval("Form")%>'
					Style="white-space: nowrap" ID="Checkbox1"></asp:CheckBox>
			</CustomItem>
			<SubGroup>
				<TemplateItem>
					<CustomItem>
						<asp:CheckBox CssClass="normal" Runat="server" Text='<%#Eval("Control")%>' style="white-space:nowrap" ID="Checkbox2" Checked='<%#Eval("IstBerechtigt")%>'>
						</asp:CheckBox>
					</CustomItem>														
				</TemplateItem>
			</SubGroup>
		</TemplateItem>
		<Bindings>
			<EO:DataBinding Property="Value" DataField="ID" Depth="2" />
		</Bindings>
	</TopGroup>																			
</EO:TreeView>


Code behind:

Code: Visual Basic.NET
Dim sql As String = "Delete From fs_Berechtigung Where fRolleID = " & newRolle.ID & "; "

		For Each formNode As EO.Web.TreeNode In trvRechte.Nodes

			If formNode.Checked Then
				sql &= "Insert Into fs_Berechtigung (fRolleID, fFunktionID) values (" & newRolle.ID & ", " & formNode.Value & "); "
			End If

			For Each controlNode As EO.Web.TreeNode In formNode.ChildNodes

				If controlNode.Checked Then
					sql &= "Insert Into fs_Berechtigung (fRolleID, fFunktionID) values (" & newRolle.ID & ", " & controlNode.Value & "); "
				End If

			Next

		Next


After execution of this code the sql still has its initial value, even if some or all nodes were checked.

Am I missing something??? Thanks.
eo_support
Posted: Friday, September 26, 2008 6:42:10 AM
Rank: Administration
Groups: Administration

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

You did more than you should. :) The TreeView supports built-in checkboxes, so you do not need to use CustomItem template to produce a checkbox. All checkbox related features works with built-in checkboxes, not checkboxes in custom item.

To enable built-in checkboxes, set CheckBoxImages.Visible to true. That should get everything working for you.

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.