How to bind DataTable to Datagrid
In cs file
DataTable employeeData = CreateDataTable();
gridEmployees.DataContext = employeeData.DefaultView;
In xaml file
<DataGrid Name="gridEmployees" ItemsSource="{Binding}">
using (SqlCeConnection con = new SqlCeConnection())
{
con.ConnectionString = connectionString;
con.Open();
SqlCeCommand com = new SqlCeCommand("SELECT S_no,Name,Father_Name")
SqlCeDataAdapter sda = new SqlCeDataAdapter(com);
System.Data.DataTable dt = new System.Data.DataTable();
sda.Fill(dt);
dataGrid1.ItemsSource = dt.DefaultView;
dataGrid1.AutoGenerateColumns = true;
dataGrid1.CanUserAddRows = false;
}
In .cs file
grid.DataContext = table.DefaultView;
In xaml file
<DataGrid Name="grid" ItemsSource="{Binding}">
You could use DataGrid in WPF
SqlDataAdapter da = new SqlDataAdapter("Select * from Table",con);
DataTable dt = new DataTable("Call Reciept");
da.Fill(dt);
DataGrid dg = new DataGrid();
dg.ItemsSource = dt.DefaultView;