问题描述
我只想在第一列('EQP_ID')中合并相同的值。如果使用“
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White" runat = "server" AutoGenerateColumns="false" OnDataBound="OnDataBound" GridLines="Both">
<Columns>
<asp:TemplateField HeaderText="EQP_ID">
<ItemTemplate>
<asp:LinkButton ID="btnIdLink" runat="server" Text='<%# Bind("EQP_ID") %>' OnCommand="LinkButton_Click" CommandName="view_detail" CommandArgument='<%# Eval("EQP_ID")%>'>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<%--<asp:BoundField DataField="EQP_ID" HeaderText="EQP_ID" ItemStyle-Width="150" />--%>
<asp:BoundField DataField="LOT_ID" HeaderText="LOT_ID" ItemStyle-Width="200" />
<asp:BoundField DataField="RESCREEN_TYPE" HeaderText="RESCREEN_TYPE" ItemStyle-Width="300" />
<asp:BoundField DataField="KEY" HeaderText="KEY" ItemStyle-Width="400" />
<asp:BoundField DataField="VALUE" HeaderText="VALUE" ItemStyle-Width="300" />
</Columns>
</asp:GridView>
protected void OnDataBound(object sender,EventArgs e)
{
for (int rowIndex = GridView1.Rows.Count - 2; rowIndex >= 0; rowIndex--)
{
GridViewRow row = GridView1.Rows[rowIndex];
GridViewRow previousRow = GridView1.Rows[rowIndex + 1];
if (row.Cells[0].Text == previousRow.Cells[0].Text)
{
row.Cells[0].RowSpan = previousRow.Cells[0].RowSpan < 2 ? 2 :
previousRow.Cells[0].RowSpan + 1;
previousRow.Cells[0].Visible = false;
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)