Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Bind XMLdatasource to in Memory XPathDocument

Bind XMLdatasource to in Memory XPathDocument

Scheduled Pinned Locked Moved ASP.NET
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GaryWoodfine
    wrote on last edited by
    #1

    Hi, I'm trying to bind the XMLDatasource to a XPATHDocument that I have retrieved from the database. Does anybody know how to do this? I have tried everything but can't seem to get it right? I am trying the asp:menu control to an xml that I am pulling straight from the DB <asp:Menu ID="mnItem" runat="server" DataSourceID="XmlDataSource1"> </asp:Menu> <asp:XmlDataSource ID="XmlDataSource1" runat="server" XPath="MenuItems/MenuItem"></asp:XmlDataSource> using (SqlConnection oConn = new SqlConnection(ConfigurationManager.ConnectionStrings["CMS"].ConnectionString)) using (SqlCommand oComm = new SqlCommand("sfspGetPageMenuItems", oConn)) { oComm.CommandType = CommandType.StoredProcedure; oConn.Open(); SqlParameter oParam = new SqlParameter("@PageID",SqlDbType.Int); oParam.Value = 1; oComm.Parameters.Add(oParam); XPathDocument xdoc = new XPathDocument(oComm.ExecuteXmlReader()); XmlDataSource1.DataFile = xdoc; }

    Kind Regards, Gary


    My Website || My Blog || My Articles

    G 1 Reply Last reply
    0
    • G GaryWoodfine

      Hi, I'm trying to bind the XMLDatasource to a XPATHDocument that I have retrieved from the database. Does anybody know how to do this? I have tried everything but can't seem to get it right? I am trying the asp:menu control to an xml that I am pulling straight from the DB <asp:Menu ID="mnItem" runat="server" DataSourceID="XmlDataSource1"> </asp:Menu> <asp:XmlDataSource ID="XmlDataSource1" runat="server" XPath="MenuItems/MenuItem"></asp:XmlDataSource> using (SqlConnection oConn = new SqlConnection(ConfigurationManager.ConnectionStrings["CMS"].ConnectionString)) using (SqlCommand oComm = new SqlCommand("sfspGetPageMenuItems", oConn)) { oComm.CommandType = CommandType.StoredProcedure; oConn.Open(); SqlParameter oParam = new SqlParameter("@PageID",SqlDbType.Int); oParam.Value = 1; oComm.Parameters.Add(oParam); XPathDocument xdoc = new XPathDocument(oComm.ExecuteXmlReader()); XmlDataSource1.DataFile = xdoc; }

      Kind Regards, Gary


      My Website || My Blog || My Articles

      G Offline
      G Offline
      GaryWoodfine
      wrote on last edited by
      #2

      I found the answer to my question. Thanks to all the guys who rushed to answer it :-) http://msdn.microsoft.com/msdnmag/issues/05/06/WickedCode/

      Kind Regards, Gary


      My Website || My Blog || My Articles

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups