日期:2014-05-17 浏览次数:20483 次
gvNet.DataSource = dt;
gvNet.DataBind();
public void GroupCol(int cols, int sRow, int eRow)
{
if (gvNet.Rows.Count < 1 || cols > gvNet.Columns.Count - 1)
{
return;
}
TableCell oldTc = gvNet.Rows[sRow].Cells[cols];
for (int i = 1; i < eRow - sRow; i++)
{
TableCell tc = gvNet.Rows[sRow + i].Cells[cols];
tc.Visible = false;
if (oldTc.RowSpan == 0)
{
oldTc.RowSpan = 1;
}
oldTc.RowSpan++;
oldTc.VerticalAlign = VerticalAlign.Middle;
}
}
public static void MergeSameRows(GridView gv, int cellNum)
{
int i = 0, rowSpanNum = 1;
while (i < gv.Rows.Count - 1)
{
GridViewRow gvr = gv.Rows[i];
for (++i; i < gv.Rows.Count; i++)
{
GridViewRow gvrNext = gv.Rows[i];
if (gvr.Cells[cellNum].Text == gvrNext.Cells[cellNum].Text)
{
gvrNext.Cells[cellNum].Visible = false;
rowSpanNum++;
}
else
&