footer totals

M

mark

im keeping running totals of certain columns in a datagrid, id like to put
these totals in the footer - how do i do this ? or how can i put a label
into the footer ? (im displaying results using labels instead at the moment)
eg



Label5.Text = "Column 1 Total:- " & mordraw & " (Ratio " &
FormatNumber(ddpercent, 2) "%)"



id like that putting in the column1 footer if possible
thanks
mark
 
M

mark

Greg Burns said:
thanks for the link but ive looked there before - it doesnt appear relevant,
im totalling on runtime using code behind like this :-

If Me.Datagrid1.Items(counter).Cells(8).Text.ToString = "" Or
Me.Datagrid1.Items(counter).Cells(8).Text.ToString = " " Then
Me.Datagrid1.Items(counter).Cells(8).Text = ""
Else : dsoi = dsoi + 1
dsoiavg = dsoiavg + Me.Datagrid1.Items(counter).Cells(8).Text.ToString
End If

be nice if i could put these totals into the footer - atm im using labels
outside the datagrid
 
G

Greg Burns

I didn't look to had a the link, it is a good starting place.

I do my totaling in ItemDataBound event of datagrid:

Private Sub grid_ItemDataBound(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles grid.ItemDataBound

If e.Item.ItemType = ListItemType.Footer Then


Dim dt As DataTable = CType(ViewState("MyData"), DataTable)
Dim dv As New DataView(dt)
dv.RowFilter = "Type <> 5" ' don't include LOW entries!!!


Dim ColTotal(7) As HourX10

Dim drv As DataRowView

For Each drv In dv

For j As Integer = 0 To 7
ColTotal(j) += CType(drv("Day" & (j + 1).ToString),
HourX10)
Next
Next

For j As Integer = 0 To MyTSDetails.WorkDays - 1
With CType(e.Item.Cells(Columns.Day1 + j).FindControl("Day"
& j + 1 & "Total"), Label)
.Text = FooterDate(MyTSDetails.WorkDays - j - 1,
ColTotal(j))
End With
Next

Dim GrandTotal As HourX10
For j As Integer = 0 To 7
GrandTotal += ColTotal(j)
Next

Dim c As TableCell = e.Item.Cells(Columns.Total)
CType(c.FindControl("lblGrandTotal"), Label).Text =
FooterGrandTotal(GrandTotal)


End If
End Sub

(Sorry I didn't generalize it more before posting)

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top