ASP.net Grid paging with merged rows

一笑奈何 提交于 2019-12-06 11:27:59

Instead of handling the merging at the UI level, would it work to prepare the data source in such a way that you can just bind directly to it?

Basically create a view model that contains the data in an easier format to bind to.

GridView.DataSource() = vmAlreadyMergedAndReadtToGoOBject
GridView.DataBind();

I am not sure where you are getting the data from, but can't you build the object you bind to your grid programatically based on the result set you get back from your source (database?) Then if you you build that object by combining the rows values that are the same you could just bind the grid to it... Not entirely clear what you are doing, but this was the first thing that came to mind....

Rock star
for (i = PagSize; i <= dt.Rows.Count; i++)
{
    Curr = dt.Rows[i - 1]["Brand"].ToString();
    if (i < dt.Rows.Count)
    {
        Nxt = dt.Rows[i]["Brand"].ToString();
        diff = dt.Rows.Count - i;
        if (Curr != Nxt)
        {
            DctPaging.Add(PageNum, i);
            PageNum = PageNum + 1;
            i = i + PagSize;
            if (i >= dt.Rows.Count)
            {
                DctPaging.Add(PageNum, i);
                break;
            }
        }
    }
}

Reference Click Here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!