salvationishere
salvationishere

Reputation: 3511

CurrencyManager alternative in vb.NET?

I am developing a VB.NET application in which I use a DataGrid; I can't use the newer DataGridView due to version. But now when I try to compile this, I get the error:

BC30002: Type 'CurrencyManager' is not defined.

It errors on line:

Dim CM As New CurrencyManager(dgTable.BindingContext)

What can I replace this line with? I have read on the internet that since my application should be web-based, I cannot use the Windows namespace. I think what I am asking for is a pretty simple solution, but I am a very new VB programmer. More of my code below.

Global.vb file:

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

and my ASPX file:

Public DSTableData As New System.Data.DataSet Public dv As New DataView

    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

Upvotes: 1

Views: 2107

Answers (1)

SLaks
SLaks

Reputation: 887453

CurrencyManager is a WinForms feature.
You cannot (and don't need to) use it in ASP.Net.

Upvotes: 1

Related Questions