开发者

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 boundfie开发者_Python百科ld(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?


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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜