Click here to Skip to main content
Rate this: bad
good
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)
    {
        GridDecorator.MergeRows(GrdReportingDetails);
    }
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
Edited 25-Apr-12 1:10am
v2

1 solution

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

Solution 1

Hi,
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.
 
SELECT
dense_rank() OVER (ORDER BY R.Request_Id) as SrNo,
R.Request_Id,
R.Request_Type,
R.Client_Name,
R.Request_Rec_On,
R.Request_Due_On,
R.Success_Flag
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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 353
1 OriginalGriff 304
2 George Jonsson 258
3 Shemeemsha RA 138
4 Animesh Datta 130
0 OriginalGriff 5,985
1 Sergey Alexandrovich Kryukov 5,341
2 CPallini 4,760
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 6 Dec 2013
Copyright © CodeProject, 1999-2014
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