private void button1_Click(object sender, RoutedEventArgs e)
{
DataTable dt = new DataTable();
string constring = "Data source=----------\\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;";
using (SqlConnection con = new SqlConnection(constring))
{
con.Open();
string cmdstring = "select * from emp";
using (SqlCommand cmd = new SqlCommand(cmdstring, con))
using (SqlDataAdapter adp = new SqlDataAdapter(cmd))
adp.Fill(dt);
}
grid_emp.ItemsSource = dt.DefaultView;
}
when clicking on button output is looking like this..

Kiran Kumar TalikotiPosted Oct 18, 2013, 2:51 AM
Make Autogeneratecolumns true in Xaml .
Hardik PatelPosted Oct 21, 2013, 2:05 AM
in .xaml.cs
Posted Oct 18, 2013, 4:16 AM
there are two conditions,
1)you have not set the Autogeneratecolumns property of gridview to true
2) if you have taken template columns int to the datagrid view set the bind path .
Posted Oct 18, 2013, 2:29 AM