<%@ Page Language="VB" AutoEventWireup="True" Debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<script runat="server">
dim MyConnection as OleDbConnection
dim cmdSelect as OleDbCommand
dim dtrReader as OleDbDataReader
dim runningTotal as double = 0
Sub Page_Load(sender As Object, e As EventArgs)
MyConnection = New OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" + Server.MapPath(".")+"/db/data.mdb")
If Not IsPostBack Then
BindGrid()
End If
End Sub
Sub BindGrid()
Dim MyCommand As OleDbDataAdapter = new OleDbDataAdapter("SELECT name,count FROM [min2]", MyConnection)
Dim DS As DataSet = new DataSet()
MyCommand.Fill(DS,"min2")
MyDataGrid.DataSource =DS.Tables("min2").DefaultView
MyDataGrid.DataBind()
End Sub
Sub MyDataGrid_ItemDataBound( sender as object, e as DataGridItemEventArgs )
if (e.Item.ItemType = ListItemType.Item or e.Item.ItemType = ListItemType.AlternatingItem) then
CalcTotal( e.Item.Cells(1).Text )
'e.Item.Cells(1).Text = string.Format("{0:c}", Convert.ToDouble(e.Item.Cells(1).Text))
else if(e.Item.ItemType = ListItemType.Footer ) then
e.Item.Cells(0).Text="Total"
e.Item.Cells(1).Text = runningTotal
e.Item.Cells(1).HorizontalAlign = HorizontalAlign.Right
end if
End Sub