如何用分页计算总和gridview? [英] How to calculate the sum gridview with paging?

查看:87
本文介绍了如何用分页计算总和gridview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有复选框,名称和成本列的网格视图,我正在使用分页。

当我选择一个复选框时我需要在分页后在文本框中添加成本在文本框中也是如此。

请有人建议我。



提前预计

I am having a gridview with a columns Checkbox,Name and "Cost" and i am using paging .
when ever i would select a checkbox i need to add the cost in a textbox after paging too in a textbox.
please could anybody suggest me.

thanx in advance

推荐答案

protected void GetPreviousTotal()

{

DataSet dset = get data from database;
OR 
DataSet dset = get data from viewstate // for this you need to store your dataset in viewstate when u get from database for the first time

for (int i = 0; i < dset.Tables[0].Rows.Count; i++)  
{
    if (i < grdBISentry.PageIndex * grdBISentry.PageSize)
    {
        total += Convert.ToDouble(dset.Tables[0].Rows[i]["COLUMN_NAME"].ToString());
    }
    else
        break;
}

} 



来自 here [ ^ ]



-KR


from here[^]

-KR


如果您需要将某些内容转发到下一页,然后你使用 Session ViewState 存储该数据,并在更改页面时读取该数据。
If you need to carry forward something to the next Page, then you have use Session or ViewState to store that Data and read that when Page is changed.


这篇关于如何用分页计算总和gridview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆