Hi people,
I have a problem with the Datagrid in WPF. I'm busy writing a WPF browser application. I have a datagrid declared on my page as follows:
<DataGrid ItemsSource="{Binding}" AutoGenerateColumns="True" Height="462" Name="dgRepair" VerticalAlignment="Top" Grid.ColumnSpan="3" Margin="0,0,1,0" RowEditEnding="dgRepair_RowEditEnding" />
Then I have code to bind data from a table to this datagrid
SqlDataAdapter RepairAD;
DataSet repairDS;
string sqlIns = @"select * from table";
SqlCommand cmd = new SqlCommand(sqlIns, conn);
RepairAD = new SqlDataAdapter(cmd);
repairDS = new DataSet();
RepairAD.Fill(repairDS, "Repair");
dgRepair.DataContext = repairDS.Tables["Repair"].DefaultView;
dgRepair.UpdateLayout();
What I need is code to update the table in the SQL database from the changes that are made in the datagrid.
I tried this code but it did nothing
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(RepairAD);
RepairAD.Update(repairDS, "Repair");
If anyone can help it would be awesome.
Thanks
ps: im using a datagrid and not a datagridview