Treeveiw Control
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngwebcontrols' list.


SNegussie@aol.com
Can a treeview web control be bound to a dataset or a datareader object? If
so, how?

S
Reply to this message...
 
    
James Avery
Can a treeview web control be bound to a dataset or a datareader object?
If
so, how?

S
Reply to this message...
 
    
SNegussie@aol.com
Can a treeview be bound to an XML DOM object or something? I really don't want to have to convert the data from a dataset to XML and then save it to file in order to bound it to tree view control. Does it only work with an XML file? Since I have multiple users accessing the application, I really don't want to incur the performance cost of accessing a file every time a user is accessing the tree.

Thanks
S

Reply to this message...
 
    
Pierre Thomasius
Hi S,

It doesn't have to be a file exactly u can write the xml to the output
stream of the aspx page u use to convert the dataset to xml.
I have conected the Treeview to a Access DB via writing the DataSet content
as xml to the outputstream and it works fine and should take much less
performance then accessing a file.

P

-----Original Message-----
From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]
Sent: 18 May 2002 18:36
To: aspngwebcontrols
Subject: [aspngwebcontrols] RE: Treeveiw Control

Can a treeview be bound to an XML DOM object or something? I really don't
want to have to convert the data from a dataset to XML and then save it to
file in order to bound it to tree view control. Does it only work with an
XML file? Since I have multiple users accessing the application, I really
don't want to incur the performance cost of accessing a file every time a
user is accessing the tree.

Thanks
S

| [aspngwebcontrols] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngwebcontrols.asp = JOIN/QUIT

Reply to this message...
 
    
Meor Zaharin Meor Ibrahim
you can directly bound to a dataset

-----Original Message-----
From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]
Sent: Sunday, May 19, 2002 1:36 AM
To: aspngwebcontrols
Subject: [aspngwebcontrols] RE: Treeveiw Control

Can a treeview be bound to an XML DOM object or something? I really =
don't want to have to convert the data from a dataset to XML and then =
save it to file in order to bound it to tree view control. Does it only =
work with an XML file? Since I have multiple users accessing the =
application, I really don't want to incur the performance cost of =
accessing a file every time a user is accessing the tree.

Thanks
S

| [aspngwebcontrols] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngwebcontrols.asp =3D JOIN/QUIT

Reply to this message...
 
    
Peter Ma
can u post some code/reference about how to bound it to a DataSet directly?
:)

[Original message clipped]

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

Reply to this message...
 
    
SNegussie@aol.com
Have you actually done this? That's directly bind a treeview control to a
dataset? If so how? How do you tell it the different levels?
Reply to this message...
 
    
SNegussie@aol.com
Hi P,

Can you give me an example? code snippets?

Thanks
S
Reply to this message...
 
    
Chesnut, Casey
Have a treeView.aspx page with a treeView control.
The control's src is treeSrc.aspx page and it points to an XSLT file.
treeSrc.aspx has no HTML in it, all it does is do a Response.Write(myDataSet.GetXML());
make sure your dataSet renders in heirarchical form, i.e. isNested=true relationships
the XSLT for transforming the serialized dataset into TreeNode format looks like this:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"; xmlns:src=" http://tempuri.org/MySchema.xsd"; xmlns:msxsl="urn:schemas-microsoft-com:xslt" version='1.0'>
<xsl:template match="/">
<TREENODES>

<xsl:for-each select="//src:Element">
<xsl:element name="TreeNode">

<xsl:attribute name="Text" ><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="Type" >Element</xsl:attribute>
<xsl:attribute name="Target" >main</xsl:attribute>
<xsl:attribute name="NavigateUrl" >main.aspx?id=<xsl:number level="multiple" format="1.1" count="src:Element | src:SubElement"/>&type=<xsl:value-of select="name()"/></xsl:attribute>

<xsl:for-each select="src:SubElement">
<xsl:element name="TreeNode">

<xsl:attribute name="Text" ><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="Type" >SubElement</xsl:attribute>
<xsl:attribute name="Target" >main</xsl:attribute>
<xsl:attribute name="NavigateUrl" >main.aspx?id=<xsl:number level="multiple" format="1.1" count="src:Element | src:SubElement"/>&type=<xsl:value-of select="name()"/></xsl:attribute>

</xsl:element>
</xsl:for-each>

</xsl:element>
</xsl:for-each>

</TREENODES>
</xsl:template>
</xsl:stylesheet>
<!--?xml-stylesheet type="text/xsl" href="MySchema.xslt"?-->

casey

-----Original Message-----
From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]
Sent: Monday, May 20, 2002 8:43 AM
To: aspngwebcontrols
Subject: [aspngwebcontrols] RE: Treeveiw Control

Have you actually done this? That's directly bind a treeview control to a dataset? If so how? How do you tell it the different levels? | [aspngwebcontrols] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngwebcontrols.asp = JOIN/QUIT
Reply to this message...
 
    
Pierre Thomasius
Hi S,

Sure here is my XML producing aspx code it writes categories and
subcategories for each dynamicly from a Access DB.

The Data access might be a bit confusing since i use my own DataObject (dll)
but all it does is return a filtered Dataset.

Hope it explains it ok check on the XML writer documentation for more help

P

<%@ Import Namespace="myComponents" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.IO" %>

<Script Language="VB" Runat="Server">

Sub Page_Load
'Sets the Context and Output stream to XML
Dim current As HttpContext

current = HttpContext.Current
current.Response.ContentType = "text/xml"
current.Response.ContentEncoding = new System.Text.UTF8Encoding()

'Calls the XML producing function and streams it to output
OutputXmlNavigation(current.Response.Output)

End Sub

Sub OutputXmlNavigation(outputWriter As TextWriter)

Dim myData As new Find()
Dim myCats As DataSet
Dim drowParent As DataRow

'Set Params
myData.Table = "Categories"
myData.DSname = "Categories"
'Gets all Categories from DB
myCats = New DataSet()
myCats = myData.Find_Item()

'--------------------------------------------------------------------
' XML ouput to Stream

Dim writer As New XmlTextWriter(outputWriter)
writer.Formatting = Formatting.Indented

writer.WriteStartDocument()
writer.WriteStartElement("TREENODES")

For each drowParent in myCats.Tables("Categories").Rows
writer.WriteStartElement("TreeNode")
writer.WriteAttributeString("Text", drowParent("category"))
writer.WriteAttributeString("DefaultStyle",
"padding:2px;background:#FFFFCC;border:solid
1px;color:black;font-size:8pt;font-name:Arial")
writer.WriteAttributeString("HoverStyle",
"color:black;font-name:Arial;border:solid 1px")
writer.WriteAttributeString("SelectedStyle",
"color:red;font-name:Arial;font-weight:bold-italic")
writer.WriteAttributeString("NAVIGATEURL", "headlines.aspx?id=" &
drowParent("cat_id"))

'Get subCats and write out XML elements
Dim mySubCat As new Find()
Dim intCatID As Integer
Dim myArray As ArrayList = New ArrayList()
Dim myTable As DataTable
Dim mySubData As DataSet
Dim drowChild As DataRow
'-------------------------------------------------
'Set Table to be searched - Set if to use Where - Set table name in
dataset
mySubCat.Table = "Subcategories "
mySubCat.Where = True
mySubCat.DSname = "Subcategories"
'-------------------------------------------------
'Set Search Params by adding String to Array
intCatID = drowParent("cat_id")
myArray.Add( "parentCat = " & intCatID )
mySubCat.Array = myArray
'-------------------------------------------------
'Get DataSet - Set Table
mySubData = mySubCat.Find_Item()
myTable = mySubData.Tables( "Subcategories" )

'Write XML Elements for subCats
For each drowChild in myTable.Rows
writer.WriteStartElement("TreeNode")
writer.WriteAttributeString("Text", drowChild("subCategory"))
writer.WriteAttributeString("DefaultStyle",
"padding:2px;background:#FFFFCC;border:solid
1px;color:black;font-size:8pt;font-name:Arial")
writer.WriteAttributeString("HoverStyle", "color:
#FF0000;background-color: #FFCC33;border : thin Black;height: auto; width:
100%;font-name:Arial")
writer.WriteAttributeString("SelectedStyle",
"color:red;font-name:Arial;font-weight:bold-italic")

writer.WriteAttributeString("NAVIGATEURL", "headlines.aspx?id=" &
drowParent("cat_id") & "&subid=" & drowChild("subcat_id"))
writer.WriteEndElement()
Next

'Close all Category and Document Elements
writer.WriteEndElement()
Next
writer.WriteEndElement()
writer.WriteEndDocument()
writer.close()

' XML output to Stream END
'--------------------------------------------------------------------

End Sub

</Script>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>

</body>
</html>
-----Original Message-----
From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]
Sent: 20 May 2002 13:43
To: aspngwebcontrols
Subject: [aspngwebcontrols] RE: Treeveiw Control

Hi P,

Can you give me an example? code snippets?

Thanks
S | [aspngwebcontrols] member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/asplists/aspngwebcontrols.asp = JOIN/QUIT
Reply to this message...
 
 
System.Collections.ArrayList
System.Data.DataRow
System.Data.DataSet
System.Data.DataTable
System.IO.TextWriter
System.Security.Cryptography.Xml.DataObject
System.Text.UTF8Encoding
System.Web.HttpContext
System.Windows.Forms.DataObject
System.Windows.Forms.TreeNode
System.Xml.Formatting
System.Xml.XmlTextWriter




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com