Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi I had a wpf datagrid with column qty and unitprice I had another column price where price=qty*unitprice but am not getting the updated value in datagrid.
I had given binding with mode as two way and update source trigger.

What I have tried:

private void CalculateProductPrice()
{
decimal productprice = 0;

for (int i = 0; i < dgvProducts.Items.Count; i++)
{
BLProducts blpro = dgvProducts.CurrentItem as BLProducts;
blpro.Price = Convert.ToDecimal(blpro.UnitPrice * blpro.Qty);
productprice += blpro.Price;
}

txtproductTotal.Text = Convert.ToString(productprice);
}

blproducts is class which contain properties price, unitprice, qty
Posted
Comments
VR Karthikeyan 3-Jun-16 6:53am    
Have you implemented INotifyPropertyChanged interface in your BLProducts class?
girishmdr 8-Jun-16 5:32am    
No But I tried in the get and set property
private decimal _price;
public decimal Price
{
get
{
_price = UnitPrice * Qty;
return _price;
}
set
{
_price = value;
}
girishmdr 8-Jun-16 5:32am    
it works fine

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900