如何显示总列数? [英] How to show total of columns ?
问题描述
当它包含String Char&我希望它在十进制中,例如Datatable Columns Contain Bal,它包含值(10Dr,20Dr其列的记录),我只需要(10 + 20)的总和然后如何获得
我尝试了什么:
我试过这个,但是它包含了char DR,它没有设置Error对象
表示如何从列值中删除charDr,即5000Dr我只想要5000个值而不是5000Dr ..
decimal totalopening = table.AsEnumerable()。Sum(row => row .Field< decimal>(Opening));
gvReport.FooterRow.Cells [1] .Text =Total;
gvReport.FooterRow.Cells [1 ] .HorizontalAlign = HorizontalAlign.Right;
gvReport.FooterRow.Cells [2] .Text = totalopening.ToString(N2);
when it Contain String Char & i want it in Decimal eg Datatable Columns Contain Bal and it contain Values (10Dr,20Dr its Record of Column ) and i want only sum of (10+20) then how to get
What I have tried:
I tried this but it contain char DR which give Error object not set
means how to remove char "Dr" from columns value ie 5000Dr i want only 5000 values not 5000Dr..
decimal totalopening = table.AsEnumerable().Sum(row => row.Field<decimal>("Opening"));
gvReport.FooterRow.Cells[1].Text = "Total";
gvReport.FooterRow.Cells[1].HorizontalAlign = HorizontalAlign.Right;
gvReport.FooterRow.Cells[2].Text = totalopening.ToString("N2");
推荐答案
使用模板列中的网格视图。然后添加Label然后将代码添加到gridrowDatabown事件中添加计算这个和精细控制以分配值。
Grid View in Used template columns. and add Label then code behind to gridrowDatabown Event in add Calculation this and fined control to assign values.
这篇关于如何显示总列数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!