本文介绍了在asp.net中的gridview中合并具有相同值的单元格时,无法获得Cell的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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;
}
}
自row.Cells [i] .Text以来,所有单元格都适用此条件=和previousRow.Cells [i] .Text =
帮助我获取网格单元格的真实文本值。
这是我的Gridview设计。
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.
<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>
推荐答案
这篇关于在asp.net中的gridview中合并具有相同值的单元格时,无法获得Cell的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!