我的程序是web 的  
aspx文件
[code=JScrip][/code]<asp:GridView ID="grv_dzsk" runat="server" AutoGenerateColumns="False"  
  Width="596px" Height="80px" onrowdatabound="grv_dzsk_RowDataBound"  
  ShowFooter="True" onrowediting="grv_dzsk_RowEditing"  
  onrowcancelingedit="grv_dzsk_RowCancelingEdit"  
  onrowupdating="grv_dzsk_RowUpdating">
  <Columns>
  <asp:BoundField DataField="sdzbm" HeaderText="经停站" ReadOnly="True" >
  <ControlStyle Width="35px" />
  <ItemStyle Width="50px" /></asp:BoundField>
  <asp:BoundField DataField="fhsl" HeaderText="件数" ReadOnly="True" >
  <ControlStyle Width="20px" />
  <ItemStyle Width="30px" /></asp:BoundField>
  <asp:BoundField DataField="fhzl" HeaderText="重量" ReadOnly="True">
  <ControlStyle Width="40px" />
  <ItemStyle Width="40px" /></asp:BoundField>
  <asp:BoundField DataField="fhtj" HeaderText="体积" ReadOnly="True">
  <ControlStyle Width="40px" />
  <ItemStyle Width="40px" /></asp:BoundField>
  <asp:BoundField DataField="fhtf" HeaderText="上付款" ReadOnly="True">
  <ControlStyle Width="40px" />
  <ItemStyle Width="40px" /></asp:BoundField>
  <asp:BoundField DataField="fhtf" HeaderText="带回运费" ReadOnly="True">
  <ControlStyle Width="40px" />
  <ItemStyle Width="60px" /></asp:BoundField>
  <asp:BoundField DataField="dzss" HeaderText="到站实收" >
  <ControlStyle Width="50px" />
  <ItemStyle Width="60px" /></asp:BoundField>
  <asp:BoundField DataField="sdzbm" HeaderText="卸货站" ReadOnly="True">
  <ControlStyle Width="35px" />
  <ItemStyle Width="50px" /></asp:BoundField>
  <asp:BoundField DataField="yjdzsj" HeaderText="预计到达时间">  
  <ControlStyle Width="120px" />
  </asp:BoundField>
  <asp:TemplateField><ItemStyle Width="40px" />   
  <ItemTemplate><asp:Button ID="Button2" runat="server" Text="编辑" CommandName="Edit"/></ItemTemplate>   
  <EditItemTemplate>   
  <asp:Button ID="Button1" runat="server" Text="更新" CommandName="Update" />   
  <asp:Button ID="Button3" runat="server" Text="取消" CommandName="Cancel"/>   
  </EditItemTemplate>   
  </asp:TemplateField>   
  </Columns>
  <FooterStyle ForeColor="Maroon" />
  </asp:GridView>
cs文件
[code=JScrip][/code]protected void Page_Load(object sender, EventArgs e)
  {
  string fhqdh = Request.Params["fhqdh"].ToString();
  DataSet ds_fhqdh = sqlhelper.GetDataSet("select fhqdh,clbh,fgsbm,fc_zdzmc,fcsj,clyf,yfyf,yfdj,khyf,fdyf,kkyf,hfyf,zcfy,xcfy,fczt,jsysfz,jsydh from fcqk where fhqdh='"+fhqdh+"'");
  if (!IsPostBack) {
  txt_fhqdh.Text = fhqdh;
  txt_fcsj.Text = ds_fhqdh.Tables[0].Rows[0]["fcsj"].ToString();
  txt_qrclbh.Text = ds_fhqdh.Tables[0].Rows[0]["clbh"].ToString();
  DataSet ds_clxx = sqlhelper.GetDataSet("select clcd,yfdj from clddxx where clbh='"+ds_fhqdh.Tables[0].Rows[0]["clbh"].ToString()+"'");
  txt_qrclcd.Text = ds_clxx.Tables[0].Rows[0]["clcd"].ToString();
  txt_qrdj.Text = ds_clxx.Tables[0].Rows[0]["yfdj"].ToString();
  txt_qrzdzmc.Text = ds_fhqdh.Tables[0].Rows[0]["fc_zdzmc"].ToString();
  txt_qrclyf.Text = ds_fhqdh.Tables[0].Rows[0]["clyf"].ToString();
  txt_qryfyf.Text = ds_fhqdh.Tables[0].Rows[0]["yfyf"].ToString();  DataSet ds_dzsk = sqlhelper.GetDataSet("SELECT distinct sdzbm,dzss,yjdzsj,SUM(fhsl) as fhsl,SUM(fhzl) as fhzl,SUM(Fhtj) as fhtj,SUM(fhxj) as fhxj,SUM(fhtf) as fhtf,SUM(fhhf) as fhhf,SUM(fhdshk) as dshk from fhxx where fhqdh='" + fhqdh + "' group by Sdzbm,dzss,yjdzsj");
  grv_dzsk.DataSource = ds_dzsk.Tables[0].DefaultView;
  grv_dzsk.DataBind();
  }
  btn_close.Attributes.Add("onclick", "guanbi();");
  }
  private int jshj = 0;
  private decimal tjhj =0;
  private decimal zlhj =0;
  private decimal fhtf = 0;
  //private decimal dzss = 0;
  protected void grv_dzsk_RowDataBound(object sender, GridViewRowEventArgs e)
  {
  if (e.Row.RowIndex >= 0)
  {
  jshj += Convert.ToInt16(e.Row.Cells[1].Text);
  zlhj += Convert.ToDecimal(e.Row.Cells[2].Text);
  tjhj += Convert.ToDecimal(e.Row.Cells[3].Text);
  fhtf += Convert.ToDecimal(e.Row.Cells[4].Text);
  //dzss += Convert.ToDecimal(e.Row.Cells[6].Text);
  }
  else if (e.Row.RowType == DataControlRowType.Footer)
  {
  e.Row.Cells[0].Text = "合计";
  e.Row.Cells[1].Text = jshj.ToString();
  e.Row.Cells[2].Text = zlhj.ToString();
  e.Row.Cells[3].Text = tjhj.ToString();
  e.Row.Cells[4].Text = fhtf.ToString();
  e.Row.Cells[5].Text = fhtf.ToString();
  //e.Row.Cells[6].Text = dzss.ToString();
  }
  //decimal clyf = Convert.ToDecimal(txt_qrclyf.Text);
  //txt_jqyf.Text =Convert.ToString(clyf - fhtf);
  //decimal jyyf = Convert.ToDecimal(txt_jyyf.Text);  }
  protected void grv_dzsk_RowEditing(object sender, GridViewEditEventArgs e)
  {
  grv_dzsk.EditIndex = e.NewEditIndex;
  bind();
  }
    
  public void bind()
  {
  string fhqdh = Request.Params["fhqdh"].ToString();
  DataSet ds_dzsk = sqlhelper.GetDataSet("SELECT distinct sdzbm,dzss,yjdzsj,SUM(fhsl) as fhsl,SUM(fhzl) as fhzl,SUM(Fhtj) as fhtj,SUM(fhxj) as fhxj,SUM(fhtf) as fhtf,SUM(fhhf) as fhhf,SUM(fhdshk) as dshk from fhxx where fhqdh='" + fhqdh + "' group by Sdzbm,dzss,yjdzsj");
  grv_dzsk.DataSource = ds_dzsk.Tables[0].DefaultView;
  grv_dzsk.DataKeyNames = new string[] { "sdzbm" };
  grv_dzsk.DataBind();
  }
  protected void grv_dzsk_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
  {
  grv_dzsk.EditIndex = -1;
  bind();
  }
  protected void grv_dzsk_RowUpdating(object sender, GridViewUpdateEventArgs e)
  {
  string fhqdh = Request.Params["fhqdh"].ToString();
  string dzss1 = ((TextBox)(grv_dzsk.Rows[e.RowIndex].Cells[6].Controls[0])).Text.ToString().Trim() ;
  sqlhelper.RunSQL("update fhxx set dzss='"+dzss1+"' where sdzbm='"+grv_dzsk.DataKeys[e.RowIndex].Value.ToString()+"'");
  }
dzss += Convert.ToDecimal(e.Row.Cells[6].Text);//这一行点击编辑的时候老是提示"输入的字符串格式不正确"