I searched Google, but I don’t even know how to correctly formulate the data. Found TriggerContext c # but it seems to me that this is not exactly that. Please advise what you can use for this. And if possible, examples.

Problem - The database has a table Orders. When adding a new order from a customer, you need to display the order information in the form of an object of the Order class. Thanks in advance!

1 answer 1

Add a DataGrid element to a WPF application.

  <DataGrid Name="dgInsuranceTypes" SelectionMode="Single"> <DataGrid.Columns> <DataGridTextColumn Header="Ид" Binding="{Binding [Id]}"></DataGridTextColumn> <DataGridTextColumn Header="Имя" Binding="{Binding [Name]}"></DataGridTextColumn> <DataGridTextColumn Header="Тариф(%)" Binding="{Binding [Tariff]}"></DataGridTextColumn> </DataGrid.Columns> </DataGrid> 

Declare the following variables:

 // Для заполнения DataGrid SqlDataAdapter da; DataSet ds; 

There is nothing left - sql query

 strTbl = "InsuranceTypes"; da = new SqlDataAdapter(@"SELECT Id, Name, Tariff FROM " + strTbl, conn); ds = new DataSet(); da.Fill(ds, strTbl); dgInsuranceTypes.ItemsSource = ds.Tables[strTbl].DefaultView;