GridView 利用 <asp:BoundField 计算总合;并在页面不展现
来源:互联网 发布:linux more命令查看 编辑:程序博客网 时间:2024/05/27 14:15
---------------------------------------------------- GridView 利用 <asp:BoundField 计算总合;并在页面不展现----------------------------------------------------
<asp:GridView ID="ReportView" runat="server" AutoGenerateColumns="False" GridLines="None" OnRowDataBound="ReportView_RowDataBound" ShowFooter="True" OnRowCreated="ReportView_RowCreated">
<Columns>
<asp:BoundField DataField="SN" HeaderText="sssssssssss"/>
<asp:BoundField DataField="RegName" HeaderText="sssssssss" />
<asp:TemplateField HeaderText="sssssss">
<ItemTemplate><%# Convert.ToDateTime(Eval("BeginTime")).ToString("yyyy-MM-dd HH:mm")%></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="eeee">
<ItemTemplate><%# Convert.ToDateTime(Eval("EndTime")).ToString("yyyy-MM-dd HH:mm")%></ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="NormalOverTotalTime" HeaderText="aaaaaa" />
<%-- <asp:TemplateField HeaderText="ccccc">
<ItemTemplate><%#Eval("NormalOverTotalTime").ToString() == "" ? "0" : Eval("NormalOverTotalTime").ToString()%>分钟</ItemTemplate>
</asp:TemplateField>--%>
<asp:TemplateField HeaderText="cccccc">
<ItemTemplate><a href="Detail.aspx?ObjID=<%# Server.UrlEncode(Eval("ObjID").ToString())%>&ddate=<%# Server.UrlEncode(this.dDate.Value.ToString())%>&edate=<%# Server.UrlEncode(this.eDate.Value.ToString())%>&rtype=0" target="_blank"><%#Eval("NormalOverDegree").ToString() == "" ? "0" : Eval("NormalOverDegree").ToString()%></a></ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="HighOverTotalTime" HeaderText="ccccccccccc" />
<%--<asp:TemplateField HeaderText="ccccccccccc">
<ItemTemplate><%#Eval("HighOverTotalTime").ToString() == "" ? "0" : Eval("HighOverTotalTime").ToString()%>分钟</ItemTemplate>
</asp:TemplateField>--%>
<asp:TemplateField HeaderText="sdssssss">
<ItemTemplate><a href="Detail.aspx?ObjID=<%# Server.UrlEncode(Eval("ObjID").ToString())%>&ddate=<%# Server.UrlEncode(this.dDate.Value.ToString())%>&edate=<%# Server.UrlEncode(this.eDate.Value.ToString())%>&rtype=1" target="_blank"><%#Eval("HighOverDegree").ToString() == "" ? "0" : Eval("HighOverDegree").ToString()%></a></ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="NormalOverDegree" HeaderText="">
<ItemStyle Width="0px" />
</asp:BoundField>
<asp:BoundField DataField="HighOverDegree" HeaderText=""/>
</Columns>
<RowStyle CssClass="tr1" />
<AlternatingRowStyle CssClass="tr0" />
</asp:GridView>
public int TotalNormalOverTotalTime = 0;
public int TotalNormalOverDegree = 0;
public int TotalHighOverTotalTime = 0;
public int TotalHighOverDegree = 0;
//先利用列计算值;
protected void ReportView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex >= 0)
{
if (!"".Equals(e.Row.Cells[4].Text) && !" ".Equals(e.Row.Cells[4].Text))
{
TotalNormalOverTotalTime += Convert.ToInt32(e.Row.Cells[4].Text);
}
if (!"".Equals(e.Row.Cells[6].Text) && !" ".Equals(e.Row.Cells[6].Text))
{
TotalHighOverTotalTime += Convert.ToInt32(e.Row.Cells[6].Text);
}
if (!"".Equals(e.Row.Cells[8].Text) && !" ".Equals(e.Row.Cells[8].Text))
{
TotalNormalOverDegree += Convert.ToInt32(e.Row.Cells[8].Text);
}
if (!"".Equals(e.Row.Cells[9].Text) && !" ".Equals(e.Row.Cells[9].Text))
{
TotalHighOverDegree += Convert.ToInt32(e.Row.Cells[9].Text);
}
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[3].Text = "合 计:";
e.Row.Cells[4].Text = TotalNormalOverTotalTime.ToString();
e.Row.Cells[5].Text = TotalNormalOverDegree.ToString();
e.Row.Cells[6].Text = TotalHighOverTotalTime.ToString();
e.Row.Cells[7].Text = TotalHighOverDegree.ToString();
}
}
//隐藏不显示的列;
protected void ReportView_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[8].Visible = false;
e.Row.Cells[9].Visible = false;
}
}
- GridView 利用 <asp:BoundField 计算总合;并在页面不展现
- cs页面动态建立gridview(BoundField)
- 获取GridView的BoundField值
- GridView中asp:BoundField的Visible=false时,无法取到这个字段的值
- ASP.NET 2.0 – 为什么替GridView的BoundField设定的DataFormatString没有效?
- 【boundfield】GridView中BoundField与TemplateField的区别_boundfield
- 将图片以二进制格式存入数据库,并以流的方式展现在jsp页面
- web developer tips (64): 在GridView中转换BoundField为TemplateField
- ASP.NET计算在页面停留时间
- 在ASP.NET中,利用GridView自定义分页
- GridView中BoundField与TemplateField的区别
- GridView中BoundField与TemplateField的区别
- 在GridView里面计算
- vs2003 asp.net中直接输出wml,并利用C#做动态页面的控制,不使用微软的移动控件
- 在iis中发布asp的网站后,只显示登陆页面,其他的页面都不显示,并出现http500内部服务器错误,是怎么回事?
- ASP.NET读取网络图片并在页面上显示
- asp.net读取Excel表并显示在页面中
- ASP.NET 后台获取HTML并在页面显示
- 上拉电阻下拉电阻的总结
- 运放设计原理
- JavaScript 编写线程代码引用Concurrent.Thread.js
- [转贴]飞电容:模拟信号隔离方法之一
- 何为三层结构体系(学学理论,但还是要做用三层结构体系作出项目后才会有更深的理解)
- GridView 利用 <asp:BoundField 计算总合;并在页面不展现
- jsp退出框架
- PKU 1821 Fence(原来DP也是会超时的。。)
- 0欧姆电阻的用途
- //根据日期计算年龄
- 斩波型开关电源
- 一个大的电容上还并联一个小电容
- 国内工作流功能特点
- 文本框输入限制大全