Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
This code is to merge cells with equal values in a GridView
but here i ma getting problem while going through this loop
<pre lang="c#"> 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;
                }
}

This condition is going to be true for all cells since row.Cells[i].Text="" and previousRow.Cells[i].Text=""
so help me to get real Text values of my grid cells.
here is my Gridview design.

C#
<asp:GridView ID="grdOverallAvg" runat="server" AutoGenerateColumns="false" DataKeyNames=""
                   AllowPaging="True" PageSize="10" Width="100%"
                   OnPageIndexChanging="grdSuggestion_PageIndexChanging"
                    önprerender="grdOverallAvg_PreRender">
                   <HeaderStyle HorizontalAlign="Center" CssClass="GridHeaderClass" />
                   <PagerStyle BackColor="#3B5998" ForeColor="White" HorizontalAlign="Center" />
                   <RowStyle HorizontalAlign="Left" CssClass="GridRowClass" />
                   <EditRowStyle BackColor="#999999" />
                   <AlternatingRowStyle CssClass="GridalternetRowClass" ForeColor="#284775" />
                   <FooterStyle CssClass="GridFooterClass" />
                  <Columns>
                       <asp:TemplateField HeaderText="Faculty" ItemStyle-Width="10%">
                           <ItemTemplate>
                               <asp:Label ID="lblfaculty" runat="server" Text='<%# Eval("faculty") %>'></asp:Label>
                           </ItemTemplate>
                       </asp:TemplateField>
                       <asp:TemplateField HeaderText="Time" ItemStyle-Width="15%">
                           <ItemTemplate>
                               <asp:Label ID="lbltime" runat="server" Text='<%# Eval("time") %>'></asp:Label>
                           </ItemTemplate>
                       </asp:TemplateField>
                       <asp:TemplateField HeaderText="Course" ItemStyle-Width="15%">
                           <ItemTemplate>
                               <asp:Label ID="lblcourse" runat="server" Text='<%# Eval("coursename") %>'></asp:Label>
                           </ItemTemplate>
                       </asp:TemplateField>
                       <asp:TemplateField HeaderText="Start Date" ItemStyle-Width="15%">
                           <ItemTemplate>
                               <asp:Label ID="lblStudname" runat="server" Text='<%# Eval("actualstdate") %>'></asp:Label>
                           </ItemTemplate>
                       </asp:TemplateField>
 </Columns>
                </asp:GridView>
Posted
Updated 16-Jul-14 23:53pm
v3

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