Asp.net 有没有办法将Gridview页脚添加为单个单元格?
我看到的所有内容都添加了一个列页脚,而不是一个完整的行控件页脚。我希望网格将页脚渲染为单个Asp.net 有没有办法将Gridview页脚添加为单个单元格?,asp.net,gridview,Asp.net,Gridview,我看到的所有内容都添加了一个列页脚,而不是一个完整的行控件页脚。我希望网格将页脚渲染为单个 <tr><td> <asp:somecontrol /> </td></tr> 浏览器中的行。我考虑过滥用寻呼机行,但它的可定制性更差。这可以在RowDataBound事件中轻松实现 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
<tr><td> <asp:somecontrol /> </td></tr>
浏览器中的行。我考虑过滥用寻呼机行,但它的可定制性更差。这可以在RowDataBound事件中轻松实现
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//check if the row is a footer row
if (e.Row.RowType == DataControlRowType.Footer)
{
//span the first cell with the number of columns
e.Row.Cells[0].ColumnSpan = e.Row.Cells.Count;
//hide all other columns
for (int i = 1; i < e.Row.Cells.Count; i++)
{
e.Row.Cells[i].Visible = false;
}
}
}
然后,第一个TemplateField可用于保存控件
<asp:TemplateField>
<ItemTemplate>
<%# Eval("myColumn") %>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="Label1" runat="server" Text="Footer"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
这可以在RowDataBound事件中轻松完成
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//check if the row is a footer row
if (e.Row.RowType == DataControlRowType.Footer)
{
//span the first cell with the number of columns
e.Row.Cells[0].ColumnSpan = e.Row.Cells.Count;
//hide all other columns
for (int i = 1; i < e.Row.Cells.Count; i++)
{
e.Row.Cells[i].Visible = false;
}
}
}
然后,第一个TemplateField可用于保存控件
<asp:TemplateField>
<ItemTemplate>
<%# Eval("myColumn") %>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="Label1" runat="server" Text="Footer"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
或者该表包含多少列?还是我误解了什么?或者该表包含多少列?还是我误解了什么?嗯,这可能比我的解决方案更有效。我还通过代码添加了按钮,但它不会触发RowCommand event.Hmmm,这可能比我的解决方案更好。我还通过代码添加了按钮,但它不会触发RowCommand事件。