2012年12月4日 星期二

加總GridView內某欄位


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

沒有留言:

張貼留言