SalesAmount字段类型为字符型.
 <%@ Page Language="VB" AutoEventWireup="True" Debug="true"%>
<%@ Page Language="VB" AutoEventWireup="True" Debug="true"%>
 <%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data" %>
 <%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data.OleDb" %>
 <script runat="server">
<script runat="server">
 Dim MyConnection as OleDbConnection
      Dim MyConnection as OleDbConnection
 
 Sub Page_Load(sender As Object, e As EventArgs)
      Sub Page_Load(sender As Object, e As EventArgs) 
 MyConnection = New OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" + Server.MapPath(".")+"/db/otherdata.mdb")
          MyConnection = New OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" + Server.MapPath(".")+"/db/otherdata.mdb")
 
 If Not IsPostBack Then
         If Not IsPostBack Then 
 BindGrid()
            BindGrid()
 End If
         End If
 End Sub
      End Sub
 
 Sub MyDataGrid_Page(sender as Object, e As DataGridPageChangedEventArgs)
      Sub MyDataGrid_Page(sender as Object, e As DataGridPageChangedEventArgs) 
 MyDataGrid.CurrentPageIndex = e.NewPageIndex
         MyDataGrid.CurrentPageIndex = e.NewPageIndex
 BindGrid()
         BindGrid()
 End Sub
      End Sub
 
 Sub BindGrid()
      Sub BindGrid() 
 Dim MyCommand As OleDbDataAdapter = new OleDbDataAdapter("Select * FROM info", MyConnection)
          Dim MyCommand As OleDbDataAdapter = new OleDbDataAdapter("Select * FROM info", MyConnection)
 Dim DS As DataSet = new DataSet()
          Dim DS As DataSet = new DataSet()
 MyCommand.Fill(DS,"info")
          MyCommand.Fill(DS,"info") 
 MyDataGrid.DataSource = DS.Tables("info").DefaultView
          MyDataGrid.DataSource = DS.Tables("info").DefaultView
 MyDataGrid.DataBind()
          MyDataGrid.DataBind()
 End Sub
      End Sub
 
 Protected Sub DataGrid_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
Protected Sub DataGrid_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) 
 If e.Item.ItemType = ListItemType.AlternatingItem OrElse e.Item.ItemType = ListItemType.Item Then
          If e.Item.ItemType = ListItemType.AlternatingItem OrElse e.Item.ItemType = ListItemType.Item Then 
 e.Item.Cells(1).ToolTip = e.Item.Cells(6).Text
             e.Item.Cells(1).ToolTip = e.Item.Cells(6).Text 
 If Convert.ToInt32(CType((e.Item.Cells(4).Controls(0)), LinkButton).Text) = 0 Then
             If Convert.ToInt32(CType((e.Item.Cells(4).Controls(0)), LinkButton).Text) = 0 Then 
 Dim wcTemp As WebControl = CType(e.Item.Cells(4).Controls(0), WebControl)
                Dim wcTemp As WebControl = CType(e.Item.Cells(4).Controls(0), WebControl) 
 wcTemp.Enabled = False
                wcTemp.Enabled = False 
 Else
             Else 
 If Convert.ToInt32(CType((e.Item.Cells(4).Controls(0)), LinkButton).Text) < 10 Then
                If Convert.ToInt32(CType((e.Item.Cells(4).Controls(0)), LinkButton).Text) < 10 Then 
 e.Item.Cells(4).ForeColor = System.Drawing.Color.Red
                   e.Item.Cells(4).ForeColor = System.Drawing.Color.Red 
 e.Item.Cells(4).Font.Bold = True
                   e.Item.Cells(4).Font.Bold = True 
 End If
                End If 
 End If
           End If 
 
 If Not (e.Item.Cells(5).Text = " ") Then
           If Not (e.Item.Cells(5).Text = " ") Then 
 If Convert.ToDouble(e.Item.Cells(5).Text) > Convert.ToDouble(100000) Then
              If Convert.ToDouble(e.Item.Cells(5).Text) > Convert.ToDouble(100000) Then 
 e.Item.BackColor = System.Drawing.Color.LightBlue
                 e.Item.BackColor = System.Drawing.Color.LightBlue 
 e.Item.ForeColor = System.Drawing.Color.SandyBrown
                 e.Item.ForeColor = System.Drawing.Color.SandyBrown 
 End If
              End If 
 e.Item.Cells(5).Text = String.Format("{0:c}", Convert.ToDouble(e.Item.Cells(5).Text))
              e.Item.Cells(5).Text = String.Format("{0:c}", Convert.ToDouble(e.Item.Cells(5).Text)) 
 Else
           Else    
 e.Item.Cells(5).Text = String.Format("{0}", "No Sales")
              e.Item.Cells(5).Text = String.Format("{0}", "No Sales") 
 e.Item.Cells(5).ForeColor = System.Drawing.Color.red
              e.Item.Cells(5).ForeColor = System.Drawing.Color.red
 End If
           End If 
 End If
         End If 
 End Sub
End Sub
 </script>
</script>
 
 <FORM id="Form1" method="post" runat="server">
<FORM id="Form1" method="post" runat="server">
 <ASP:DATAGRID id="MyDataGrid"
      <ASP:DATAGRID id="MyDataGrid" 
 width="90%"
                    width="90%" 
 runat="server"
                    runat="server" 
 autogeneratecolumns="False"
                    autogeneratecolumns="False" 
 showfooter="False"
                    showfooter="False"
 BACKCOLOR="#E0E0E0"
                    BACKCOLOR="#E0E0E0"
 OnItemDataBound="DataGrid_ItemDataBound">
                    OnItemDataBound="DataGrid_ItemDataBound">
 <ALTERNATINGITEMSTYLE BACKCOLOR="Silver"></ALTERNATINGITEMSTYLE>
        <ALTERNATINGITEMSTYLE BACKCOLOR="Silver"></ALTERNATINGITEMSTYLE>
 <HEADERSTYLE FONT-BOLD="True" FORECOLOR="White" BACKCOLOR="Black"></HEADERSTYLE>
        <HEADERSTYLE FONT-BOLD="True" FORECOLOR="White" BACKCOLOR="Black"></HEADERSTYLE>
 <COLUMNS>
        <COLUMNS>
 <asp:BoundColumn DataField="ProductID" HeaderText="Product ID">
          <asp:BoundColumn DataField="ProductID" HeaderText="Product ID">
 <ITEMSTYLE HORIZONTALALIGN="Left"></ITEMSTYLE>
            <ITEMSTYLE HORIZONTALALIGN="Left"></ITEMSTYLE>
 </asp:BoundColumn>
          </asp:BoundColumn>
 <asp:BoundColumn DataField="ProductName" HeaderText="Product Name">
          <asp:BoundColumn DataField="ProductName" HeaderText="Product Name">
 <ITEMSTYLE HORIZONTALALIGN="Left"></ITEMSTYLE>
            <ITEMSTYLE HORIZONTALALIGN="Left"></ITEMSTYLE>
 </asp:BoundColumn>
          </asp:BoundColumn>
 <asp:BoundColumn DataField="CategoryName" HeaderText="Category ">
          <asp:BoundColumn DataField="CategoryName" HeaderText="Category ">
 <ITEMSTYLE HORIZONTALALIGN="Right"></ITEMSTYLE>
            <ITEMSTYLE HORIZONTALALIGN="Right"></ITEMSTYLE>
 </asp:BoundColumn>
          </asp:BoundColumn>
 <asp:BoundColumn DataField="SubCategoryName" HeaderText="Sub Category">
          <asp:BoundColumn DataField="SubCategoryName" HeaderText="Sub Category">
 <ITEMSTYLE HORIZONTALALIGN="Right"></ITEMSTYLE>
            <ITEMSTYLE HORIZONTALALIGN="Right"></ITEMSTYLE>
 </asp:BoundColumn>
          </asp:BoundColumn>
 <asp:ButtonColumn DataTextField="NoOfSales" HeaderText="Sales Count" CommandName="CountOnClick">
          <asp:ButtonColumn DataTextField="NoOfSales" HeaderText="Sales Count" CommandName="CountOnClick">
 <ITEMSTYLE HORIZONTALALIGN="Right"></ITEMSTYLE>
            <ITEMSTYLE HORIZONTALALIGN="Right"></ITEMSTYLE>
 </asp:ButtonColumn>
          </asp:ButtonColumn>
 <asp:BoundColumn DataField="SalesAmount" HeaderText="Sales Amount" >
          <asp:BoundColumn DataField="SalesAmount" HeaderText="Sales Amount" >
 <ITEMSTYLE HORIZONTALALIGN="Right"></ITEMSTYLE>
            <ITEMSTYLE HORIZONTALALIGN="Right"></ITEMSTYLE>
 </asp:BoundColumn>
          </asp:BoundColumn>
 <asp:BoundColumn DataField="ProductModelName" Visible=False ></asp:BoundColumn>
          <asp:BoundColumn DataField="ProductModelName" Visible=False ></asp:BoundColumn>          
 </COLUMNS>
        </COLUMNS>
 </ASP:DATAGRID>
      </ASP:DATAGRID>
 </FORM>
</FORM>
    
                    
                     
                    
                 
                    
                

 
                
            
         
         
 浙公网安备 33010602011771号
浙公网安备 33010602011771号