วันศุกร์ที่ 6 มิถุนายน พ.ศ. 2557

asp.net : Gridview Footer

การใช้งาน Footer ใน gridview ของ asp.net

ต้องการ





 ใน event RowDataBound ของ gridview

 Protected Sub GridView1_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        ' check row type
        If e.Row.RowType = DataControlRowType.DataRow Then
            ' if row type is DataRow, add RoomNumber value to TotalSales
            TotalRoomNumber += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "RoomNumber"))
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            ' If row type is footer, show calculated total value
            e.Row.Cells(4).Text = "รวม"
            e.Row.Cells(5).Text = TotalRoomNumber.ToString("d")
            e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Center              e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Center
            e.Row.Font.Bold = True  
        End If
    End Sub

ไม่มีความคิดเห็น:

แสดงความคิดเห็น