seesea125(雨天) 说得好精采。
我的问题解决了。现在将分页汇总的心得总结如下。
1,根据sql语句得到dataset,在绑定dataset.tables.item(0).defaultview之前取得你要的汇总数据如下:
Private Sub bind()
Dim i As Integer
da = func1.getDataAdapter(sql.ToString)
ds = New DataSet
da.Fill(ds, "table0")
dg1.Style.Clear()
'********获得汇总数据
For i = 0 To ds.Tables(0).Rows.Count - 1
jimao_total += ds.Tables(0).Rows.Item(i).Item("技工贸总收入")
infact_total += ds.Tables(0).Rows.Item(i).Item("利润总额")
industry_total += ds.Tables(0).Rows.Item(i).Item("工业利润")
tax_total += ds.Tables(0).Rows.Item(i).Item("实际上缴税费总额")
yr_total += ds.Tables(0).Rows.Item(i).Item("营业税")
enterprise_total += ds.Tables.Item(0).Rows.Item(i).Item("企业所得税")
other_total += ds.Tables(0).Rows(i).Item("其他附加税费")
person_total += ds.Tables(0).Rows(i)("个人所得税")
Next
Response.Write(other_total)
dg1.DataSource = ds.Tables(0).DefaultView
dg1.DataBind()
End Sub
2.
2,在datagird的itemdatabound事件中。
执行以下代码:
‘+++++++++++showfooter=true
If e.Item.ItemType = ListItemType.Footer Then
e.Item.Cells(0).Text = jimao_total.ToString("C")
e.Item.Cells(1).Text = infact_total.ToString("C")
e.Item.Cells(2).Text = industry_total.ToString("C")
e.Item.Cells(3).Text = tax_total.ToString("C")
e.Item.Cells(4).Text = yr_total.ToString("C")
e.Item.Cells(5).Text = enterprise_total.ToString("C")
e.Item.Cells(6).Text = other_total.ToString("C")
e.Item.Cells(7).Text = person_total.ToString("C")
End If
因为datagrid.databind之后,才发生itemdatabound事件,所以取得数据一定要在datagridl.databind之前