本文介绍了gridview row sum itemtemplate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在尝试girdview,其中每行总计将显示 < gridview> < asp:TemplateField> < itemtemplate> getprice(DataBinder.Eval( Container.DataItem,unit_price)) < itemtemplate> < asp:TemplateField> < itemtemplate> getqty(DataBinder.Eval(Container.DataItem,unit_qty)) < asp:TemplateField > < ItemTemplate > lable_id =总计 < / ItemTemplate > ; < / asp:TemplateField > unit_price unit_qty总计 100 2 200 i无法得到总数200 请帮助如何排行每一行并获得输出总数解决方案 在网格中添加一个空列, 之后在行绑定事件上使用以下代码, b $ b 受保护 void gridView1_RowDataBound( object sender,GridViewRowEventArgs e) { if ( e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells [ 10 ]。Text = Convert.ToInt32(e .Row.Cells [ 8 ]。文本)* Convert.ToInt32(e.Row.Cells [ 9 ]文本)。 } } < / pre > 您好, 请从此链接获取帮助: http://www.aspdotnet-suresh.com/2011/02/how-to-display-sum-of-columns-total-in.html [ ^ ] 可能会帮助你,如果没有请告诉我。 谢谢。 i am trying for girdview where each row total is to be displayed< gridview><asp:TemplateField><itemtemplate>getprice(DataBinder.Eval(Container.DataItem, unit_price))<itemtemplate><asp:TemplateField><itemtemplate>getqty(DataBinder.Eval(Container.DataItem, unit_qty))<asp:TemplateField><ItemTemplate>lable_id=total</ItemTemplate></asp:TemplateField>unit_price unit_qty total100 2 200i am unable to get total as 200please help how to rowbound each row and get the output total 解决方案 Hi,Add an empty column in the grid,after that on row bound event use the following code,protected void gridView1_RowDataBound(object sender, GridViewRowEventArgs e){if (e.Row.RowType == DataControlRowType.DataRow){e.Row.Cells[10].Text = Convert.ToInt32(e.Row.Cells[8].Text) * Convert.ToInt32(e.Row.Cells[9].Text);}}</pre>Hi,Please take help from this link:http://www.aspdotnet-suresh.com/2011/02/how-to-display-sum-of-columns-total-in.html[^]may be it ll help you if not please let me know.Thanks. 这篇关于gridview row sum itemtemplate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-11 18:51