我要删除的网格视图单元格合并中的问题从单元格中删除重复的记录 [英] problem in merging in gridview cell i want to remove remove dulicate record from cell

查看:131
本文介绍了我要删除的网格视图单元格合并中的问题从单元格中删除重复的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果单元格中有重复记录,如何合并asp.net中的单元格
我正在使用此代码,但是在合并数据显示在网格外部之后,我也使用了分页
代码在这里
公共类GridDecorator
{
公共静态无效MergeRows(GridView gridView)
{
for(int rowIndex = gridView.Rows.Count-2; rowIndex> == 0; rowIndex--)
{
GridViewRow row = gridView.Rows [rowIndex];
GridViewRow previousRow = gridView.Rows [rowIndex +1];

for(int i = 0; i< row.Cells.Count; i ++)
{
如果(row.Cells [i] .Text == previousRow.Cells [i] .Text)
{
row.Cells [i] .RowSpan = previousRow.Cells [i] .RowSpan< 2? 2:
previousRow.Cells [i] .RowSpan +1;
previousRow.Cells [i] .Visible = false;
}
}
}
}
}

//合并单元格
受保护的void gvbenefit_PreRender(对象发送者,EventArgs e)
{
GridDecorator.MergeRows(gvbenefit);

}


索赔ID



利益类型

糖尿病供应商








-------------------------------------------------- ------------------------------








计费程序

索赔编号ID

Dos

程序代码

修饰符

单位

账单金额

支付金额



A4253

1234E1231121

1

1

A

1

12000

12000











小计

5

64000

69000











小计

8

52597

53701









小计

8

125476

81478





小计

1

12000

12000

how to merge cells in asp.net if i have duplicate record in cell
i am using this code but after merging data is showing outside of grid i used paging also
code is here
public class GridDecorator
{
public static void MergeRows(GridView gridView)
{
for (int rowIndex = gridView.Rows.Count - 2; rowIndex >= 0; rowIndex--)
{
GridViewRow row = gridView.Rows[rowIndex];
GridViewRow previousRow = gridView.Rows[rowIndex + 1];

for (int i = 0; i < row.Cells.Count; i++)
{
if (row.Cells[i].Text == previousRow.Cells[i].Text)
{
row.Cells[i].RowSpan = previousRow.Cells[i].RowSpan < 2 ? 2 :
previousRow.Cells[i].RowSpan + 1;
previousRow.Cells[i].Visible = false;
}
}
}
}
}

//Merging cell
protected void gvbenefit_PreRender(object sender, EventArgs e)
{
GridDecorator.MergeRows(gvbenefit);

}


Claim ID



Benefit Type

Diabetic Supplier








--------------------------------------------------------------------------------








Billed Procedures

Claim Number ID

Dos

Procedure Code

Modifier

Units

Bill Amount

Paid Amount



A4253

1234E1231121

1

1

A

1

12000

12000











Sub Total

5

64000

69000











Sub Total

8

52597

53701









Sub Total

8

125476

81478





Sub Total

1

12000

12000

推荐答案

我在代码项目中找到了此链接.也许这可能对您有帮助.

消除Gridview中的重复行. [
I found this link in code project. Maybe this might help you.

Eliminating Duplicate rows in Gridview.[^]

I have a few thoughts that may help as I don''t know all the specifics, but let me know if any of this points you in the proper direction.

1. What do you consider duplicate data? This question should prompt you to start thinking along the lines of what constitutes a duplicate such that you can find a remedy to your situation.

2. Before calling this function can you organize the data and remove duplicates before calling it? As a thought what about placing the data in a collection and try to see if you can find duplicates by iterating through all the collection. Not sure if that is a good idea because depending upon quantity of data it may be a bad idea.

3. As I have mentioned before I don''t know the specifics, but I was faced in a situation similar to this (again I don''t know your specifics). What I did to remedy my duplicates was to take care of it at the database level up creating multiple queries to merge 3 tables into one and remove all duplicates if any.

I hope these thoughts help. Don''t give up :). Keep on programming!


尝试一下,

Try this,

public static void GridView_Row_Merger(GridView gridView)
    {
        for (int rowIndex = gridView.Rows.Count - 2; rowIndex >= 0; rowIndex--)
        {
            GridViewRow currentRow = gridView.Rows[rowIndex];
            GridViewRow previousRow = gridView.Rows[rowIndex + 1];

            for (int i = 0; i < currentRow.Cells.Count; i++)
            {
                if (currentRow.Cells[1].Text == previousRow.Cells[1].Text)
                {
                    if (previousRow.Cells[1].RowSpan < 2)
                        currentRow.Cells[1].RowSpan = 2;
                    else
                        currentRow.Cells[1].RowSpan = previousRow.Cells[1].RowSpan + 1;
                    previousRow.Cells[1].Visible = false;
                    if (currentRow.Cells[2].Text == previousRow.Cells[2].Text)
                    {
                        if (previousRow.Cells[2].RowSpan < 2)
                            currentRow.Cells[2].RowSpan = 2;
                        else
                            currentRow.Cells[2].RowSpan = previousRow.Cells[2].RowSpan + 1;
                        previousRow.Cells[2].Visible = false;
                    }
                }

            }
        }
    }


这篇关于我要删除的网格视图单元格合并中的问题从单元格中删除重复的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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