Click here to Skip to main content
12,886,892 members (35,528 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hi ,

This code does not works for merged rows.I want to get the Serial number for Merged rows. For example there are 3 colums C1(seria no),C2,C3. For one value of C2 there is multiple values of C3. Therefore I have merged C2 for same values. But I am not able to get serial number for C2.

I am using below code for Merging the C2 for same values:

protected void GrdReportingDetails_PreRender(object sender, EventArgs e)
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 = 1; 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;
Posted 25-Apr-12 0:02am
Updated 25-Apr-12 1:10am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I didn't get any C# code for the issue. But if the data is coming from SQL Stored Proc, we can get the readymade serial number using a one liner in the stored proc.

dense_rank() OVER (ORDER BY R.Request_Id) as SrNo,
From REQ_Request R.

dense_rank() OVER (ORDER BY R.Request_Id) will solve the query and you may just display the Stored proc output in the gridview.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 6 Dec 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100