下面是datagrid增加合计行的文章
http://www.dotnetjunkies.com/Article/2F527E21-A6C5-497A-8B56-4150BDAF711D.dcik
至于你说的
"随着手工不断的输入,下面的合计及时的更新"
应该用客户端脚本去实现了

解决方案 »

  1.   

    可以给textbox绑定onblur事件
    用js写
      

  2.   

    to smilnet(笨笨):能给个例子吗?谢谢!
      

  3.   

    没弄过,想必DataGrid里动态放置textbox,结合onblur事件关注
    帮你up
      

  4.   

    比如说你的页面上有一个tb_Sum的TextBox来计算合计给你的用来输入的TextBOx标签加上onblur = Sum(this)
    如下:<asp:TextBox id="TextBox1" runat="server" TextMode="Password" onblur = Sum(this)></asp:TextBox>
    在你的html下面加上js方法
    <script language =javascript>function Sum(varTb)
    {
    //如果什么都没有输入,直接退出
       var value = varTb.value;
    if(value == "")
    return true;

    var rx = new RegExp("(\\d{1,}\\.\\d{1,4})|\\d{1,}");
    var matches =rx.exec(value);
    if((matches != null && value == matches[0]))
    {
    //输入0,退出
    if( value == 0)
    {
    return;
    }

    //累计
    var price = document.all.<%= tb_Sum.ClientID %>.value;

    price = price + value;

    document.all.<%= tb_Sum.ClientID %>.value = price;
    }
    else
    {
    //s输入不正确
    alert("请输入正确的金额!");
    varTb.value = "";
    varTb.focus();
    }
    }</script>
      

  5.   

    http://msdn.microsoft.com/library/en-us/dndive/html/data01102002.asp?frame=true
      

  6.   

    see
    Summary Rows in a DataGrid: A Comparison of Techniques
    http://www.aspalliance.com/olson/articles/summary.aspx
      

  7.   

    http://search.csdn.net/Expert/topic/2314/2314994.xml?temp=.5719263
      

  8.   

    如果是在WinForm底下的DataGrid就不能用JS了,该怎么实现呀?
      

  9.   

    我的这样可以:
    private void dg1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    { //获取模板列,给模板列赋值
    //string sl="",dj="";
    //decimal hj=0;
    int sl=0;
    decimal dj=0,hj=0;

    for (int i=0;i<=dg1.Items.Count;i++)
    {
    //sl=Convert.ToInt32(e.Item.Cells[3].Text);
    //dj=Convert.ToDecimal(e.Item.Cells[4].Text);
    //sl=e.Item.Cells[3].Text;
    //dj=e.Item.Cells[4].Text;
    try
    {


    Label lb1=(Label)e.Item.FindControl("lb1");
    if (lb1!=null)
    {
    sl=Convert.ToInt32(e.Item.Cells[3].Text);
    dj=Convert.ToDecimal(e.Item.Cells[4].Text);

    hj=sl*dj;
    zj=zj+hj;
    lb1.Text=hj.ToString();
    }
    }
    catch
    {
    Response.Write("输出错误");
    } }
    Label lb_hj=(Label)e.Item.FindControl("lb_hj");
    if (lb_hj!=null)
    {
    lb_hj.Text=zj.ToString();
    }
    }
    }
      

  10.   

    用textbox的textchange()事件也可以的,添加行后,重新绑定datagrid