Click here to Skip to main content
15,902,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to restrict one column should not repeat with other row in repeater

HTML
|---------|---------|----------|----------|
| data    | data    |data      | data     |
|         |         |----------|          |
|         |         |data      |          |
|         |         |----------|          |
|         |         |data      |          |
|---------|---------|----------|----------|
| data    | data    |data      | data     |
|         |         |----------|          |
|         |         |data      |          |
|         |         |----------|          |
|         |         |data      |          |
|---------|---------|----------|----------|
| data    | data    |data      | data     |
|         |         |----------|          |
|         |         |data      |          |
|         |         |----------|          |
|         |         |data      |          |
|         |         |----------|          |
|         |         |data      |          |
|         |         |----------|          |
|         |         |data      |          |
|---------|---------|----------|----------|

ASP.NET
 <ItemTemplate>
    <td align="center">
                                                                                    <asp:Label ID="lblGrade" runat="server" Text='<%#Eval("Grades")%>'></asp:Label>
                                                                                </td>
 <td align="center">
<%#Eval("Grade_point")%>
                                                                                </td>
 <td align="center">
                                                                                    <%#Eval("CREDITS_POINT")%>
</td>
<td align="center">
                                                                                    <asp:Label ID="lblRptrCredit" runat="server" Text='<%#Eval("CG")%>'></asp:Label>
 </td>

<td rowspan="7" >
 NA
</td>
</tr>
 </ItemTemplate>
Posted
Updated 16-Apr-13 23:15pm
v2
Comments
vijay__p 17-Apr-13 5:18am    
Can you please elaborate more regarding your question?
Member-515487 17-Apr-13 5:30am    
I want to RowSpan

1 solution

I suggest you to perform this in gridview as follows:

C#
<asp:GridView ID="GridView6" runat="server" AutoGenerateColumns="false"
                            OnPreRender="GridView6_PreRender" >
                            
                            <Columns>
                                <asp:BoundField DataField="one" HeaderText="" SortExpression="code" />
                                <asp:BoundField DataField="two" HeaderText="" SortExpression="name" />
                                <asp:BoundField DataField="three" HeaderText="" SortExpression="date1"
                                     />
                                <asp:BoundField DataField="four" HeaderText="" SortExpression="leave" />
                                <asp:BoundField DataField="five" HeaderText="" SortExpression="ltype" />
                            </Columns>
                        </asp:GridView> 


On prerender event call the MergeRows function:

C#
protected void GridView6_PreRender(object sender, EventArgs e)
        {
            MergeRows(GridView6);
        }


And below is the function:

C#
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 - 2; 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;
                    }
                }
            }
        }


Hope this helps.!
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900