在asp.net的GridView中求和列值

本文关键字:求和 GridView asp net | 更新日期: 2023-09-27 18:05:17

我试图在Gridview中SUM日期列。请参考我的代码。编译器错误-不能将int转换为string。

请建议。

感谢
protected void GridViewFortNight_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            TimeSpan timeSpent = TimeSpan.Parse("00:00:00");
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                timeSpent += TimeSpan.Parse(DataBinder.Eval(e.Row.DataItem, "TimeSheetDayTotal"));
            }
            else if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[4].Text = timeSpent.ToString(@"dd':hh':mm");
            }
        }

在asp.net的GridView中求和列值

你已经在gridview页脚添加了一个标签。Gridview行更新事件你已经计算它。我希望你能理解。