protected void gvInfos_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            int sumdays = 0;
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //sumdays = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "WDays"));
                //sumdays = int.Parse(DataBinder.Eval(e.Row.DataItem, "WDays").ToString());
                sumdays = int.Parse(e.Row.Cells[2].Text);
            }
            else if (e.Row.RowType == DataControlRowType.Footer)  //页脚 
            {
                e.Row.Cells[0].Visible = false;
                e.Row.Cells[1].Text = "合计:";
                e.Row.Cells[1].ColumnSpan = 2;
                e.Row.Cells[1].HorizontalAlign = HorizontalAlign.Right;
                e.Row.Cells[2].Text = sumdays.ToString();
            }
        }

解决方案 »

  1.   

    应该是没有执行这:
    if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    //sumdays = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "WDays"));
                    //sumdays = int.Parse(DataBinder.Eval(e.Row.DataItem, "WDays").ToString());
                    sumdays = int.Parse(e.Row.Cells[2].Text);
                }
      

  2.   

    onrowdatabound="gvInfos_RowDataBound" 前台已经加了这个啊控件上?
      

  3.   

    int sumdays;
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    //sumdays = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "WDays"));
                    //sumdays = int.Parse(DataBinder.Eval(e.Row.DataItem, "WDays").ToString());
                    sumdays = int.Parse(e.Row.Cells[2].Text);
                }
               
      if (e.Row.RowType == DataControlRowType.Footer)  //页脚 
                {
                    e.Row.Cells[0].Visible = false;
                    e.Row.Cells[1].Text = "合计:";
                    e.Row.Cells[1].ColumnSpan = 2;
                    e.Row.Cells[1].HorizontalAlign = HorizontalAlign.Right;
                    e.Row.Cells[2].Text = sumdays.ToString();
                }
      

  4.   

    参考:
    http://www.cnblogs.com/insus/articles/1433589.html