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.
you may need cast though. once grab , identify summary row, style differently.
hope makes sense.