Bind XMLdatasource to in Memory XPathDocument
-
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
-
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
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