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; } }
<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>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)