asp.net - how to add footer row dynamically for every 10 records in gridview using c#.net -


i trying break gridview rows fro every 10 records in gridview.it working fine 1 more thing need. 10 records need add footer row , have calculate sum of 10 rows in grid view .

this code breaking grid view...

protected void gvpartywisereport_rowdatabound(object sender, gridviewroweventargs e) {     if (e.row.rowtype == datacontrolrowtype.datarow)     {         tempcounter = tempcounter + 1;         if (tempcounter== 10)         {             e.row.attributes.add("style", "page-break-after: always;");         }     } } 

please body me in way. in advance.

in opinion - easiest way manipulate back-end data-set or data-source grid bound rather creating , inserting footer row in rowdatabound event.

iterate on data-set before binding data , add summary row every ten records. add property "ispagesummary" in data item flags whether summary record , not real data item.

inside rowdatabound event, grab summary record separately using "ispagesummary" property. access underlying data object using e.dataitem.

https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridviewrow.dataitem%28v=vs.110%29.aspx

you may need cast though. once grab , identify summary row, style differently.

hope makes sense.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -