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. Advertising

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,177
    HNguyen
    Jun 3, 2004
  2. HNguyen

    Binding data from XQuery to a dataset

    HNguyen, Jun 3, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    399
    HNguyen
    Jun 3, 2004
  3. Stylus Studio
    Replies:
    0
    Views:
    397
    Stylus Studio
    Sep 20, 2005
  4. Doug.Net

    Limited (partial) Binding of DataSet in DataGrid

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

    Binding DataGrid TemplateColumns to ChildTable of DataSet

    Axel Reimann, Apr 7, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    189
    Axel Reimann
    Apr 7, 2004
Loading...

Share This Page