title: WPF Databinding: How can I bind a stored procedure to a Listview
body: <p>I have a button that when clicked will run a stored procedure on a SQL Server and display the resulting data in a grid within the same window.</p>
  
  <p>In windows forms world, I'd create a datatable, use a dataadapter to fill it and then assign the datatable to the DataSource propert of my DataGridView and poof... there's my data.  </p>
  
  <p>I'm tried something similar in WPF using a ListView with a Gridview and i cant seem to make it work.  I have the following in my XAML: 
  <code></p>
  
  <pre><code>&lt;ListView Grid.Row="1" Name="Preview" ItemsSource="{Binding Path=Report}"&gt;
    &lt;GridView&gt;
      &lt;GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=FormalName}" /&gt;
    &lt;/GridView&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p></code></p>
  
  <p>And in my C# code</p>
  
  <pre><code>private void CreateReport(object sender, RoutedEventArgs e) 
  {
    DataTable dt = new DataTable("Report");
    SqlConnection cn = new SqlConnection("Data Source=DailyTimesheets;
               Initial Catalog=DailyTimesheets;Integrated Security=SSPI");
  
    SqlCommand cm = new SqlCommand("Reports.PayrollHoursInterface", cn);
    cm.Parameters.AddWithValue("@PayBatchID", 722);
    cm.CommandType = CommandType.StoredProcedure;
  
    SqlDataAdapter da = new SqlDataAdapter(cm);
    da.Fill(dt);
  
    Preview.DataContext=dt;
  }
  </code></pre>
  
  <p>When I clicka the button (that fires the CreateReport Method), my datatable gets filled and assigned to the Datacontext, but nothing displays.  </p>