Hello again,
I have read that it is not possible to get a grand total ina datagrid. (adding all the rows of a particular column) I was wondering though, is it possible to find teh grand total another way an display it in a label somewhere on the form. The column I want to total is one that I create at run time. Here is the code I use to create the "Total" row. What code do I need to total all the rows within the column?
OleDbDataAdapter1.SelectCommand.Parameters(0).Value = txtinvnum.Text
OleDbDataAdapter1.Fill(DSInvoice1)
Try
DSInvoice1.Tables(0).Columns.Remove("Total"
Catch
End Try
DSInvoice1.Tables(0).Columns.Add("Total"
Dim dr As DataRow
If rdoyes.Checked Then
For Each dr In DSInvoice1.Tables(0).Rows
dr.Item("Total"
= ((dr.Item("QuantityShipped"
* dr.Item("LastUnitPrice"
) * (1 - dr.Item("DiscountP"
))
Next
grdcomm.DataSource = Nothing
grdcomm.SetDataBinding(DsInvoice1, "Invoicehistory"
ElseIf rdono.Checked Then
For Each dr In DSInvoice1.Tables(0).Rows
dr.Item("Total"
= dr.Item("QuantityShipped"
* dr.Item("LastUnitPrice"
Next
grdcomm.DataSource = Nothing
grdcomm.SetDataBinding(DsInvoice1, "Invoicehistory"
End If
I have read that it is not possible to get a grand total ina datagrid. (adding all the rows of a particular column) I was wondering though, is it possible to find teh grand total another way an display it in a label somewhere on the form. The column I want to total is one that I create at run time. Here is the code I use to create the "Total" row. What code do I need to total all the rows within the column?
OleDbDataAdapter1.SelectCommand.Parameters(0).Value = txtinvnum.Text
OleDbDataAdapter1.Fill(DSInvoice1)
Try
DSInvoice1.Tables(0).Columns.Remove("Total"
Catch
End Try
DSInvoice1.Tables(0).Columns.Add("Total"
Dim dr As DataRow
If rdoyes.Checked Then
For Each dr In DSInvoice1.Tables(0).Rows
dr.Item("Total"
Next
grdcomm.DataSource = Nothing
grdcomm.SetDataBinding(DsInvoice1, "Invoicehistory"
ElseIf rdono.Checked Then
For Each dr In DSInvoice1.Tables(0).Rows
dr.Item("Total"
Next
grdcomm.DataSource = Nothing
grdcomm.SetDataBinding(DsInvoice1, "Invoicehistory"
End If