Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET 2.0: How to bind an asp:Menu to an SqlDataSource?
    text
    copied!<p>i've found how to bind an asp:Menu to XML. i've found how to bind an asp:Menu to a site map (which is really binding it to XML). How do you bind an asp:Menu to a database?</p> <p>The .NET Framework provides multiple data sources:</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.hierarchicaldatasourcecontrol.aspx" rel="noreferrer">HierarchicalDataSourceControl</a></li> <li><ul> <li><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.xmldatasource.aspx" rel="noreferrer">XmlDataSource</a></li> </ul></li> <li><ul> <li><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sitemapdatasource.aspx" rel="noreferrer">SiteMapDataSource</a></li> </ul></li> <li><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.datasourcecontrol.aspx" rel="noreferrer">DataSourceControl</a></li> <li><ul> <li><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.aspx" rel="noreferrer">SqlDataSource</a></li> </ul></li> <li><ul> <li><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.accessdatasource.aspx" rel="noreferrer">AccessDataSource</a></li> </ul></li> <li><ul> <li><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linqdatasource.aspx" rel="noreferrer">LinqDataSource</a></li> </ul></li> </ul> <p>i want to use one that represents data from an SQL Server table. The data is stored in the standard <a href="http://www.answers.com/hierarchical" rel="noreferrer">hierarchical</a> format that everyone uses:</p> <pre><code>NodeID ParentNodeID Caption Url ======== ============== ========= ================= {3234... {3632... stackoverflow http://stackov... {3632... (null) Questions ~/questions.aspx {3233... (null) Tags ~/tags.aspx {3235... {3632... google http://www.goo... </code></pre> <p>And the query to return all the rows would be:</p> <pre><code>SELECT * FROM Nodes </code></pre> <p>What is the secret method that Microsoft intended me to use to mash that data into an asp:Menu?</p> <hr> <p><strong>Update:</strong> There is a good article on aspalliance.com: <a href="http://aspalliance.com/822" rel="noreferrer">Building a Database Driven Hierarchical Menu using ASP.NET 2.0</a>. Unfortunatly it describes how to perform XML data binding; while i'm interested in database binding.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload