使用ItemTemplate在第一列中具有合并单元格的Gridview

问题描述

我只想在第一列('EQP_ID')中合并相同的值。如果使用“ ”,则可以使它工作,但是如果使用“ ItemTemplate”,“受保护的无效的OnDataBound(对象发送者,EventArgs e)”,它将不再起作用。这是我的下面的代码。感谢有人可以帮助解决这个问题。

<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 (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...