Csharp89
Csharp89

Reputation: 1

Working out math percentages per row in a gridview

Hello I have a gridview which looks like:

Boundfield(string), Boundfield(decimal), button1, button2, button3, button4, button5, label

button1, 2, 3, 4, 5 and label are inside a template field.

Based on what button is pressed:

  1. Button 1 - 100% which should work out 100% of boundfield(decimal) = label1
  2. Button 2 - 80% which should work out 80% of boundfield(decimal) = label
  3. Button 3- 60% which should work out 60% of boundfield(decimal) = label
  4. Button 4 - 40% which should work out 40% of boundfield(decimal) = label
  5. Button 5 20% which should work out 20% of boundfield(decimal) = label

This should work out seperate sums based on each row I can imagine it to auto generate the sum for every label in the gridview which i don't want.

Is this possible and if so how could you go about doing it?

Upvotes: 0

Views: 220

Answers (2)

Beth
Beth

Reputation: 9607

Are you sure you don't want to do these calculations upstream? You may not have permission to modify the datasource to include these calculations, but if you do, pls. consider doing them there.

Upvotes: 0

Landern
Landern

Reputation: 374

Assuming the ItemsSource is bound to some custom type(class) that represents the rows in the GridView, add another bound property with a default value for the label. When the user clicks on one of the buttons, update the label's property for that row's index in the collection of your type, done!

Upvotes: 0

Related Questions