2011-05-17 27 views
1

我正在開發一個VB.NET應用程序,我在其中使用DataGrid;由於版本的原因,我無法使用較新的DataGridView。但現在,當我嘗試編譯,我得到的錯誤:CurrencyManager在vb.NET中的替代?

Dim CM As New CurrencyManager(dgTable.BindingContext)

我能替換爲這一行:

BC30002: Type 'CurrencyManager' is not defined.

上線它的錯誤?我在互聯網上看過,既然我的應用程序應該是基於網絡的,我不能使用Windows命名空間。我想我所要求的是一個非常簡單的解決方案,但我是一個非常新的VB程序員。下面我的更多代碼。

Global.vb文件:

Imports System.Data 
Imports System.Data.OLEDB 
Imports System.Web 
Imports System.Math 
Imports system.data.SqlClient 
Imports System.Windows.Forms 
Imports System.Windows.Forms.CurrencyManager 

Namespace GlobalFunctions 
    Public Class GlobalF 
     Public Shared Function GlobalF_Load(ByVal dgTable As DataGrid) 
      Dim dv As New DataView 
      Dim ds As New DataSet 
      Dim CM As New CurrencyManager(dgTable.BindingContext) 

      dv = New DataView(ds.Tables(0)) 
      dgTable.DataSource = dv 

      dv.Sort = "Part No." 
      'CM = (System.Windows.Forms.CurrencyManager) 
      dgTable.BindingContext([dv]) 
      Dim sender As New sender() 

      dv.ListChanged += New ListChangedEventHandler(dv_ListChangedEvent) 
     End Function 

     Public Shared Function btnFind_Click(ByVal sender As Object, ByVal e As EventArgs) 
      If (txtFind.Text = "") Then 
       Response.write("Enter some criteria to find.") 
       txtFind.Focus() 
      Else 
       Dim i As Int 
       i = dv.Find(txtFind.Text) 
       If (i > dv.Table.Rows.Count Or i < 0) Then 
        Response.Write("Record Not found") 
       Else 
        CM.Position = i 
       End If 
      End If 
     End Function 

     Private Shared Function dv_ListChangedEvent(ByVal sender As Object, ByVal e As ListChangedEventArgs) Handles btnFind.ListChanged 
      If (dv.Sort.Substring((dv.Sort.Length - 4), 4) = "DESC") Then 
       lblFind.Text = "Enter Search Criteria " + dv.Sort.Substring(0, dv.Sort.Length - 5) 
      Else 
       lblFind.Text = "Enter Search Criteria " + dv.Sort 
      End If 
     End Function 

和我的ASPX文件:

公共DSTableData作爲新System.Data.DataSet中 公共DV作爲新的數據視圖

Sub Main() 
     '------------------------- Query database and get arrays for the chart and bind query results to datagrid ----------------------------------------                

     If check1.Checked Then 
      DSTableData = GlobalFunctions.GlobalF.FillSparePartsTable(1) 
     Else 
      DSTableData = GlobalFunctions.GlobalF.FillSparePartsTable(0) 
     End If 

     'dv = DataView(DSTableData(0)) 
     dgTable.DataSource = DSTableData 
     dgTable.DataBind() 

     GlobalFunctions.GlobalF.GlobalF_Load(dgTable) 

    End Sub 

回答

1

CurrencyManager是WinForms功能。
你不能(也不需要)在ASP.Net中使用它。