Get Values From Table and Sum it, depend of selected date

• Question

• I do not know exactly how to describe, but I look for the solution to the following problem. I have two tables one is rooms with different options and prices, second table has increased the price depends on the date, like in image

Depends on the options of accommodations in ListView options appears type of apartment like in img

Using datatable i receiv this figure

It is ok, but limits me, in case if the customer wants to add another type of apartment

trying different method  finaly i create some like above but problem is in first item in the ListView Sum increased is ok (40) but in second item i have total.

It is maybe a different method, but at the present day I have eclipse in my mind,
can use the Dictionary or IList ?, I do not know what would be more effective
```//Id of room type
int ROID = int.Parse(RTyp.Text);

var pq = from prod in _db.ApartPrice
where prod.StartPrice <= day && prod.EndPrice >= day && prod.RTId == ROID
group prod by prod.RTId into gr
select new
{
TotalPrice = gr.Sum(p => p.Price)
};

decimal MySuma = 0;
{

foreach (var grp in pq)
{
MySuma = grp.TotalPrice;
KL += MySuma;
}
}```

Saturday, February 27, 2016 1:36 AM

• simple solution is everytime the best

```decimal MK = 0;
{
var ro = _db.ApartPrice.Where(s => s.StartPrice <= day && s.EndPrice >= day && s.RTId == ROID);
foreach (var item in ro)
{
MK += item.Price;
}
}```

And effect. All price is correct depend of type of room, including when cliebt want insert another typ of room.

because the controls (Label) do not exist yet the formula must be in OnItemDataBound

• Marked as answer by Saturday, February 27, 2016 9:49 PM
Saturday, February 27, 2016 9:45 PM