GridView加入自动求和求平均值小计.doc

GridView加入自动求和求平均值小计.doc

  1. 1、本文档共4页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
GridView加入自动求和求平均值小计

GridView加入自动求和求平均值小计 图: 解决方案: private double sum 0;//取指定列的数据和,你要根据具体情况对待可能你要处理的是int protected void GridView1_RowDataBound object sender, GridViewRowEventArgs e if e.Row.RowIndex 0 sum + Convert.ToDouble e.Row.Cells[6].Text ; else if e.Row.RowType DataControlRowType.Footer e.Row.Cells[5].Text 总薪水为:; e.Row.Cells[6].Text sum.ToString ; e.Row.Cells[3].Text 平均薪水为:; e.Row.Cells[4].Text int sum / GridView1.Rows.Count .ToString ; 后台全部代码: using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using System.Drawing; public partial class Default7 : System.Web.UI.Page SqlConnection sqlcon; SqlCommand sqlcom; string strCon Data Source local ;Database 北风贸易;Uid sa;Pwd sa; protected void Page_Load object sender, EventArgs e if !IsPostBack bind ; protected void GridView1_RowEditing object sender, GridViewEditEventArgs e GridView1.EditIndex e.NewEditIndex; bind ; protected void GridView1_RowUpdating object sender, GridViewUpdateEventArgs e sqlcon new SqlConnection strCon ; string sqlstr update 飞狐工作室 set 姓名 + TextBox GridView1.Rows[e.RowIndex].Cells[1].Controls[0] .Text.ToString .Trim + ,家庭住址 + TextBox GridView1.Rows[e.RowIndex].Cells[3].Controls[0] .Text.ToString .Trim + where 身份证号码 + GridView1.DataKeys[e.RowIndex].Value.ToString + ; sqlcom new SqlCommand sqlstr, sqlcon ; sqlcon.Open ; sqlcom.ExecuteNonQuery ; sqlcon.Close ; GridView1.EditIndex -1; bind ; protected void GridView1_RowCancelingEdit object sender, GridViewCancelEditEventArgs e GridView1.EditIndex -1; bind ; public void bind string sqlstr select top 5 * from 飞狐工作室; sqlcon new SqlConnection strCon ; SqlDataAdapter myda new SqlDataAdapter sqlstr, sqlcon ; DataSet myds new DataSet ; sqlcon.Open ; myda.Fill myds, 飞狐工作室 ; GridView1.DataSource myd

文档评论(0)

sh4125733 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档