I have开发者_Go百科 a WPF DataGrid
with a data source of DataTable
. This DataGrid
has just one column that is not ReadOnly
where the user must enter data. How i can get values?
This is how i bind the data to the grid.
ConstructTable();
foreach (CheckOutData col in _CheckOutCollection)
{
decimal paidMoney = 0;
if (col.PaidMoney <= 0)
{
paidMoney = 0;
}
else
{
paidMoney = col.PaidMoney;
}
dt.Rows.Add(
col.ID.ToString(),
col.RoomType.ToString(),
col.RoomNumber.ToString(),
col.RoomPriceWithCurrency.ToString(),
col.Discount.ToString(),
col.DiscountedPriceWithCurrency.ToString(),
col.CheckIn.ToString(),
col.CheckOut.ToString(),
col.TotalDay.ToString(),
col.TotalPrice.ToString(),
col.IncFirstDay.ToString(),
paidMoney.ToString());
_CheckInsIDs.Add(col.ID);
}
dataGrid1.DataContext = ds.Tables[0];
I'm selecting data from an SQL Table int a Collection
col
. As above, this Collection
is used to populate the DataTable
.
i dont use more this _CheckOutCollection
You need to use two way mode in your datagrid column binding like below :
Binding="{Binding ColName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
精彩评论