gridview简单问题

chenyu112 2009-03-04 11:05:56
gridview中的ShowFooter="True"
可是前台显示时此行的列数要比上面的列数多
程序如下:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
Response.Write(e.Row.Cells.Count + "aa");//此处得得到每行的值是12
if (e.Row.RowType == DataControlRowType.Footer)
{
int cellcount = e.Row.Cells.Count;

for (int i = 1; i < e.Row.Cells.Count; i++)
{
e.Row.Cells.Remove(e.Row.Cells[i]);
}
e.Row.Cells[0].ColumnSpan = cellcount;
e.Row.Cells[0].Text = "总计: 交易笔数" + count.ToString() + "笔,数量" + sellsum.ToString() + ",销售总额" + string.Format("{0:C}", sum);
}

}
前台页面:
<asp:GridView ID="GridView1" runat="server" AllowPaging="false" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="AreaId" ForeColor="#333333" GridLines="None" Height="35"
OnRowCommand="GridView1_RowCommand" PagerSettings-Visible="false" Width="100%"
OnRowDataBound="GridView1_RowDataBound" ShowFooter="true">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle CssClass="srow" />
<EditRowStyle CssClass="seditrow" />
<SelectedRowStyle CssClass="selectrow" />
<PagerStyle BackColor="Transparent" ForeColor="White" VerticalAlign="Top" />
<HeaderStyle CssClass="stitle" />
<AlternatingRowStyle CssClass="salternatrow" />
<Columns>
<asp:BoundField DataField="AreaName" HeaderText="产品名称" />
<asp:BoundField DataField="AreaName" HeaderText="a" />
<asp:BoundField DataField="AreaName" HeaderText="b" />
<asp:BoundField DataField="AreaName" HeaderText="c" />
<asp:BoundField DataField="AreaID" HeaderText="d" DataFormatString="{0:C}" />
<asp:BoundField DataField="AreaID" HeaderText="e" DataFormatString="{0:C}" />

<asp:BoundField DataField="AreaID" HeaderText="e" />
<asp:BoundField DataField="AreaID" HeaderText="f" />
<asp:TemplateField HeaderText="状态">
<ItemTemplate>
成功
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="AreaID" HeaderText="a" />
<asp:BoundField DataField="AreaId" HeaderText="bb" />
<asp:TemplateField HeaderText="cc">
<ItemTemplate>
<a href="ComplaintsProduct.aspx?ProductId=<%# DataBinder.Eval(Container.DataItem,"areaid")%>">aa</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Visible="False" />
</asp:GridView>
...全文
100 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zuoming120 2009-03-04
  • 打赏
  • 举报
回复
chenyu112 2009-03-04
  • 打赏
  • 举报
回复
<table cellspacing="0" cellpadding="4" border="0" id="GridView1" style="color:#333333;height:35px;width:100%;border-collapse:collapse;">
<tr class="stitle">
<th scope="col">产品名称</th><th scope="col">二级</th><th scope="col">直登陆名</th><th scope="col">登陆名</th><th scope="col">二级进价</th><th scope="col">进价</th><th scope="col">网吧售价</th><th scope="col">数量</th><th scope="col">状态</th><th scope="col">定单号</th><th scope="col">玩家帐号</th><th scope="col">投诉</th>
</tr><tr class="srow" ondblclick="javascript:OpenWeb('BillInfo.aspx?BillNo=110107')">
<td>石景山区</td><td>石景山区</td><td>石景山区</td><td>石景山区</td><td>¥110,107.00</td><td>¥110,107.00</td><td>110107</td><td>110107</td><td>
成功
</td><td>110107</td><td>110107</td><td>
<a href="ComplaintsProduct.aspx?ProductId=110107">投诉</a>
</td>
</tr>
<tr class="salternatrow" ondblclick="javascript:OpenWeb('BillInfo.aspx?BillNo=110108')">
<td>海淀区</td><td>海淀区</td><td>海淀区</td><td>海淀区</td><td>¥110,108.00</td><td>¥110,108.00</td><td>110108</td><td>110108</td><td>
成功
</td><td>110108</td><td>110108</td><td>
<a href="ComplaintsProduct.aspx?ProductId=110108">投诉</a>
</td>
</tr><tr style="color:White;background-color:#507CD1;font-weight:bold;">
<td colspan="12">总计: 交易笔数10笔,数量1100936,销售总额¥121,206,017,404.00</td><td> </td><td> </td><td> </td><td> </td><td> </td>
</tr>
</table>
这是右键源文件部分的内容
注意一下各行的列数,不知道最下面一行中后台的几个空列是怎么来的
源程序如1楼所示
xfreyes 2009-03-04
  • 打赏
  • 举报
回复
你搞错了吧,到底用的head还是footer
统一一下应该就好了
或者都用
金大哈 2009-03-04
  • 打赏
  • 举报
回复
没有说明白
小宏 2009-03-04
  • 打赏
  • 举报
回复
做个记号
smallerwood 2009-03-04
  • 打赏
  • 举报
回复
可是前台显示时此行的列数要比上面的列数多 ? 不懂
chenyu112 2009-03-04
  • 打赏
  • 举报
回复
知道是哪的原因了
原来是
for (int i = 1; i < e.Row.Cells.Count; i++)
在捣乱

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧