dim count as integer Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound '個人習慣將要加的欄位轉成template If e.Row.RowType = DataControlRowType.DataRow Then dim countval as label = e.Row.FindControl("加總欄位id") count += CType(countval.Text, Integer) elseIf e.Row.RowType = DataControlRowType.Footer Then e.Row.Cells(0).Text = "總分:" e.Row.Cells(1).Text = count end if end sub
2012年12月4日 星期二
加總GridView內某欄位
DataTable的某個欄位作加總
DataTable dt = new DataTable(); string s_sum = dt .Compute("SUM(欄位名稱)", "").ToString();
訂閱:
文章 (Atom)