CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

MS SQL 2008 on ASP.NET Hosting



Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 9/27/2005 4:32:36 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 10 Views: 35 Favorited: 0 Favorite
11 Items, 1 Pages 1 |< << Go >> >|
mariolopes
Asp.Net User
TreeView with xml file9/27/2005 4:32:36 PM

0/0

Hello
I need to populate a treeview control with one xml file. First: What kind of xml strutucre  file i have to use?
I have 3 textboxes (or a datalist) in my form.When i choose one item from the treeview i want the textboxes gets one xml node value.
For example in the following file when i select Application i want to show  "3:06 PM 10/7/2002"  and ="Process A"
<Events>
 <EventLog Name="Application">
  <Information ="3:06 PM 10/7/2002" DateTime Source="Process A">
   Application Starting
....  
Thank you

Mario Lopes
jdixon
Asp.Net User
Re: TreeView with xml file9/28/2005 2:38:45 PM

0/0

Sorry for the poor formatting - this should get you going though,
HTH
JD

XML File:
<Events>
<
EventLog Name="Application">
<
Information DateTime="3:06 PM 10/7/2002" Source="Process A">
Application Starting
</Information>
<
Information DateTime="3:10 PM 10/7/2002" Source="Process B">
Connecting to Network
</Information>
<
Warning DateTime="3:11 PM 10/7/2002" Source="Process B">
Network Unavailable...Retrying
</Warning>
<
Information DateTime="3:12 PM 10/7/2002" Source="Process A">
Application Shutdown
</Information>
<
Error DateTime="3:25 PM 10/7/2002" Source="Process B">
Connection Timeout Exceeded
</Error>
</
EventLog>
<
EventLog Name="Security"/>
<
EventLog Name="System"/>
</
Events>

ASPX file:

<%@ Page Language="VB" %>
<%
@ Import Namespace="System.Xml" %>
<html>
<head id="Head1" runat="server"/>
<script language="VB" runat="server">
Sub MyTreeView_SelectedNodeChanged(sender As Object, e As EventArgs)
Dim path As String = MyTreeView.SelectedNode.DataPath
MyDetailsSource.XPath = path
MyDataList.DataSource = MyDetailsSource
MyDataList.DataBind()
End Sub
</script>
<body>
<form id="Form1" runat="server">
<asp:XmlDataSource Id="MySource" DataFile="~/XMLFile.xml" XPath="Events/EventLog" runat="server"/>
<asp:TreeView Id="MyTreeView" DataSourceId="MySource" MaxDataBindDepth="1" OnSelectedNodeChanged="MyTreeView_SelectedNodeChanged" runat="server">
<Databindings>
<asp:TreeNodeBinding DataMember="EventLog" TextField="Name" SelectAction="Expand" />
<asp:TreeNodeBinding DataMember="Information" TextField="DateTime"/>
<asp:TreeNodeBinding DataMember="Error" TextField="DateTime"/>
<asp:TreeNodeBinding DataMember="Warning" TextField="DateTime"/>
</Databindings>
</asp:TreeView>
<asp:XmlDataSource Id="MyDetailsSource" DataFile="~/XMLFile.xml" runat="server"/>
<asp:DataList Id="MyDataList" runat="server">
<ItemTemplate>
<asp:TextBox ID="TextBox0" runat="server" Text='<%# XPath("@DateTime") %>'></asp:TextBox><br />
<asp:TextBox ID="TextBox2" runat="server" Text='<%# XPath("@Source") %>' ></asp:TextBox><br />
</ItemTemplate>
</asp:DataList>
</form>
</body>
</
html>


This posting is provided "AS IS" with no warranties, and confers no rights.
We Are Hiring
mariolopes
Asp.Net User
Re: TreeView with xml file9/29/2005 2:12:48 PM

0/0

Hello
Works fine
Thank you


Mario Lopes
mariolopes
Asp.Net User
Re: TreeView with xml file - Session?10/4/2005 5:32:11 PM

0/0

Again
I need to save the <%# XPath("@DateTime") %> in a session variable. Please How can i achieve this?
Thanks


Mario Lopes
JoeBerg
Asp.Net User
Re: TreeView with xml file - Session?10/5/2005 4:46:18 PM

0/0

You can get the XmlDocument of the DataSource and query on it:

      Session["firstDateTime"] = XmlDataSource1.GetXmlDocument().SelectSingleNode("//@DateTime[1]").Value;

Hope this helps,
Joe

mariolopes
Asp.Net User
Re: TreeView with xml file - Session?10/5/2005 5:17:30 PM

0/0

Ok

We are on the right track.
I have one more problem because i get allways the same value (when i change my treeview value   i allways get the value .....SelectSingleNode("//@DateTime[1]").Value;).
How can i change the index [1] accordly?


Mario Lopes
JoeBerg
Asp.Net User
Re: TreeView with xml file - Session?10/5/2005 5:50:01 PM

0/0

Yes, that XPath using DateTime[1] will return only the first DateTime that it finds. You could use any other index to get to the DateTime you desire. I'm not sure how you want to store your data, but here's another approach:

int i = 0;
foreach (XmlNode node in XmlDataSource1.GetXmlDocument().SelectNodes("//@DateTime"))
         Session[
"DateTime" + i++.ToString()] = node.Value;

Hope this helps,
Joe
jdixon
Asp.Net User
Re: TreeView with xml file - Session?10/5/2005 6:45:43 PM

0/0

This would work to a point. I suggest using the xpath that you get from DataPath and do a concat with the data that you want, ala:

VB:
Session.Add(
"DateTime", MyDetailsSource.GetXmlDocument().SelectSingleNode(path + "//@DateTime").Value)

This way you will get just the DateTime from the extact node that you are after\selected in the tree.

Hope this helps

JD


This posting is provided "AS IS" with no warranties, and confers no rights.
We Are Hiring
mariolopes
Asp.Net User
Re: TreeView with xml file - Session?10/5/2005 7:12:50 PM

0/0

Session.Add("DateTime", MyDetailsSource.GetXmlDocument().SelectSingleNode(path + "//@DateTime").Value)
How can i obtain the path value?
Mario Lopes
jdixon
Asp.Net User
Re: TreeView with xml file - Session?10/5/2005 8:12:25 PM

0/0



Sub MyTreeView_SelectedNodeChanged(sender As Object, e As EventArgs)
Dim path As String = MyTreeView.SelectedNode.DataPath
MyDetailsSource.XPath = path
MyDataList.DataSource = MyDetailsSource
MyDataList.DataBind()
Session.Add("DateTime", MyDetailsSource.GetXmlDocument().SelectSingleNode(path + "//@DateTime").Value)
End Sub

HTH

JD

This posting is provided "AS IS" with no warranties, and confers no rights.
We Are Hiring
mariolopes
Asp.Net User
Re: TreeView with xml file - Session?10/6/2005 1:32:21 PM

0/0

JD

Works fine!!

Thanks everybody


Mario Lopes
11 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
Professional ASP.NET 3.5: In C# and VB Authors: Bill Evjen, Scott Hanselman, Devin Rader, Pages: 1673, Published: 2008
ASP.NET 3.5 For Dummies Authors: Ken Cox, Pages: 404, Published: 2008
Microsoft Visual C# 2005 Unleashed Authors: Kevin Hoffman, Pages: 692, Published: 2006
Visual Basic 2005 Cookbook: Solutions for VB 2005 Programmers Authors: Tim Patrick, John Craig, John Clark Craig, Pages: 713, Published: 2006
Pro .NET 2.0 XML Authors: Bipin Joshi, Pages: 499, Published: 2007
Beginning ASP.NET 2.0 Databases: Beta Preview Authors: John Kauffman, Thiru Thangarathinam, Pages: 427, Published: 2005
Extending MFC Applications with the .NET Framework Authors: Tom Archer, Nishant Sivakumar, Pages: 656, Published: 2003
Beginning ASP.NET 2.0 Authors: Chris Hart, John Kauffman, Chris Ullman, David Sussman, Pages: 759, Published: 2005
SAS/Graph 9.1 Reference, 2-Volume Set: Volumes 1, 2 And 3 Authors: SAS Institute, SAS Institute, Pages: 1628, Published: 2004

Web:
How To Populate a Treeview Control with an XML File Visual Basic .NET308063 For a Microsoft Visual Basic .NET version of this article, see 308063. This article illustrates how to populate a Treeview control ...
ASP.NET.4GuysFromRolla.com: Displaying XML Data in the Internet ... Specifically, we can bind the contents of an XML file to the TreeView. The rub of all of this is that the XML file must be in the following precise format: ...
DisplayXmlFile - loading a XML file in a TreeView Display a XML file in a TreeView Note: requires Imports System.Xml Example: DisplayXmlFile(employees.xml, TreeView1)
CodeProject: Save a TreeView into an XML File. Free source code ... The article includes a sample project showing how to save the nodes of a TreeView into an XML file.; Author: Norbert Eder; Section: C / C++ Language; ...
Generating a tree view using XSL and XML What is a Tree View? 3. The XML/XSL files for the Tree View: 3.1. The XML data file: 3.2. The XSL script file: 3.3. The XSL include file; 4. ...
15 Seconds : Populating the TreeView Control from a Database Create the following XML file called XMLFile1.xml and save it in the same directory as your TreeView aspx file. . ...
Exporting a TreeView to XML. Populating a TreeView from XML This article will show you techniques you can use to export tree view items to an XML file, and how to construct a tree view from an XML document. ...
CodeProject: Loading and Saving a TreeView control to an XML file ... Demonstrates how to serialize and de-serialize the contents of System.Windows. Forms.TreeView control from an XML file using forward only, ...
Display XML File Contents on a TreeView Control More information: This function displays opens an XML file and displays it ( retaining its hierarchical structure) on a TreeView control, using the XML ...
Re: Populate Windows Forms TreeView from XML file - MSDN Forums Jul 21, 2008 ... Re: Populate Windows Forms TreeView from XML file ... I have a TreeView that I am trying to populate from this XML file: ...

Videos:
Structuring Personal Information When Everything Can Be Saved and Searched... Google TechTalks May 17, 2006 William Jones William Jones is an Research Associate Professor in The Information School at the University of Washingt...




Search This Site:










how do i programmatically edit a theme or skin file

dynamically adding link button to pagertemplate

using html in a menu <staticitemtemplate>

javascript in masterpages

dynamic popout menu being hidden behind a custom user control? please help!

using 2 sitemaps getting a small conflict

theme not working properly

contents from masterpage disappearing

treeview not causing validation

asp.net navigation

treeview, sitemapdatasource, sitemap and caching

expanded node style in treeview control

master page, content page -> outputcache doesn't seem to work

is it possible to update the control at server-side ?

menu control

page load error i can not find in dec ctp

form tag in master page

update label in masterpage from another page

bc30456: 'theme' is not a member of 'asp.default_aspx'.

how do i access functions on a basepage from a masterpage?

asp.net dynamic dropdown menu

how to organize tags in the head when using masterpage and theme

menu's backcolor

is it possible to build the treeview from the child up vs the parent down?

intermittent exception with master page

apparent bug with the asp.net 2.0 menu control and master pages

asp:menu gives server error

sitemappath and server.transfer woes

question about roles attribute

how do i find out the size (height) of a contentplaceholder

  Privacy | Contact Us
All Times Are GMT