Binding data from XQuery to a dataset and show on datagrid

Discussion in 'ASP .Net Datagrid Control' started by HNguyen, Jun 3, 2004.

  1. HNguyen

    HNguyen Guest

    Hi,

    I have a problem of binding data from XQuery to a dataset. Here is the
    program I've extracted from 4guysfromrolla.com. This program read data from
    an XML file (Employees.xml) and performed XQuery from this XML file. The
    program ran OK to show the XML data on the Literal control. Instead of
    displaying XML data on that control, I'd like to bind XML data to a dataset
    and display them on Datagrid control (not in XML data format). Please help
    me to solve it !!!

    My e-mail is
    Thanks in advance.

    Hiep

    ================================================================
    (Employees.aspx)

    <%@ Page Language="vb" debug="true" %>
    <%@ Import Namespace="Microsoft.Xml.XQuery" %>

    <script runat="server">
    Sub Page_Load(sender as Object, e as EventArgs)
    Dim col as New XQueryNavigatorCollection()
    col.AddNavigator(Server.MapPath("Employees.xml"), "Emp")

    Dim query as string
    query="<Emp>{for $myNode in document(""Emp"")//Employees where
    $myNode/Route=""K-22"" return $myNode}</Emp>"

    Dim expr as New XQueryExpression(query)
    lblXML.Text = (expr.Execute(col)).ToXml()

    End sub
    </script>

    <html>
    <body>
    <xmp>
    <asp:Literal runat="server" id="lblXML" />
    </xmp>
    </body>
    </html>

    =======================================================================

    (Employees.xml)

    <?xml version="1.0" standalone="yes"?>
    <NewDataSet>
    <Employees>
    <ID>1</ID>
    <LastName>Jackson</LastName>
    <FirstName> Alan</FirstName>
    <Phone>(703) 123-4567</Phone>
    <Room>430</Room>
    <Route>K-22</Route>
    <Gov>1</Gov>
    <Status>ND</Status>
    </Employees>
    <Employees>
    <ID>2</ID>
    <LastName>Robin</LastName>
    <FirstName> Tim</FirstName>
    <Phone>(703) 234-5678</Phone>
    <Room>412</Room>
    <Route>K-15</Route>
    <Gov>0</Gov>
    <Status>ND</Status>
    </Employees>
    <NewDataSet>
     
    HNguyen, Jun 3, 2004
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HNguyen
    Replies:
    0
    Views:
    1,278
    HNguyen
    Jun 3, 2004
  2. Jordan
    Replies:
    2
    Views:
    2,741
    Jordan
    Feb 10, 2004
  3. HNguyen

    Binding data from XQuery to a dataset

    HNguyen, Jun 3, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    477
    HNguyen
    Jun 3, 2004
  4. =?Utf-8?B?Zm9ubnlsYXNtYW5h?=

    My datagrid does not show the query from dataset

    =?Utf-8?B?Zm9ubnlsYXNtYW5h?=, Feb 13, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    545
    =?Utf-8?B?Zm9ubnlsYXNtYW5h?=
    Feb 13, 2006
  5. Doug.Net

    Limited (partial) Binding of DataSet in DataGrid

    Doug.Net, Jul 3, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    195
    James J. Foster
    Jul 3, 2003
  6. Axel Reimann

    Binding DataGrid TemplateColumns to ChildTable of DataSet

    Axel Reimann, Apr 7, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    263
    Axel Reimann
    Apr 7, 2004
  7. JcFx
    Replies:
    0
    Views:
    507
  8. Novice
    Replies:
    0
    Views:
    176
    Novice
    May 7, 2004
Loading...