简体   繁体   中英

how to sum particular column values page wise in gridview while printing

sno name  salary

1    xx    10000

2    vv     5000

2    ss   25000

........ 

like this i have 100 records in gridview. Now I want Print This gridview with 20 records per page and in footer i have to show sum of total salary in that page.

For example in bank statement we will get page wise sum of credit and debit balance like that.

I have a gridview with 100 records and A print button. When i click on print button,it is showing gridview in 5 pages. Now i want to sum particular column values in that page and show that sum value in a lable. similarly for all pages i want to sum page values.

Please any body help me in that way.
Thanks in advance

First you want to write code for finding 20 record and then write below code for sum of perticular column in gridview

public int total = 0;

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
                    {  


                        if (e.Row.RowType == DataControlRowType.DataRow)
                        {
                            int qty = int.Parse(e.Row.Cells[0].Text);
                            total = total + qty;
                            TextBox1.Text = total.ToString();
                        }
                    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM