title: Bind DropDownList with Hierarchy from SQL Server Table with ASP.NET
body: <p>I have the following sql table which contains menu (website menu) data.</p>
  
  <p>Table Name: MenuItems<br>
  Columns: Id, MenuId, ParentMenuItemId, Text.  </p>
  
  <p>My goal is to bind a DDL according to the following hierarchy (example):  </p>
  
  <pre><code>Id: 1, MenuId: 1, ParentMenuItemId: -1, Text: 'One'  
  Id: 2, MenuId: 1, ParentMenuItemId: 1, Text: 'Two'  
  Id: 3, MenuId: 1, ParentMenuItemId: 1, Text: 'Three'  
  Id: 4, MenuId: 1, ParentMenuItemId: 2, Text: 'Four'  
  Id: 5, MenuId: 1, ParentMenuItemId: 4, Text: 'Five'  
  </code></pre>
  
  <p>Requested result in DDL:  </p>
  
  <pre><code>One  
  -- Two  
  ---- Four    
  ------ Five  
  -- Three  
  </code></pre>
  
  <p>I think it should contain <code>WITH</code> SQL command.  </p>
  
  <p>Note: I'm using C#.</p>