Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binding data to a variable of the object datatype
Message
From
25/08/2003 03:49:12
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Binding data to a variable of the object datatype
Miscellaneous
Thread ID:
00822980
Message ID:
00822980
Views:
66
Hi there I'm pretty new to the .NET Framework and ASP.NET.

I'm building a data class and I wanted to build a general function (see code below) wich binds data to a control supplied as parameter (like a datagrid or listbox):
Public Sub BindToControl(ByRef objControl As Object)
  '--- Declare local variables
  Dim dadAdapter As SqlDataAdapter
  Dim dstDataSet As DataSet
  Dim conDatabase As SqlConnection
  Dim strConnString As String
  Dim strSQL As String

  strConnString = "Server=127.0.0.1;UID=sa;PWD=;Database=Northwind;"
  strSQL = "SELECT ContactName FROM Customers"

  '--- Initialize an instance of the connection object
  conDatabase = New SqlConnection(strConnString)

  '--- Create an instance of the dataset object
  dstDataSet = New DataSet()

  '--- Initialize an instance of the sqldataadapter object
  dadAdapter = New SqlDataAdapter(strSQL, conDatabase)
  dadAdapter.Fill(dstDataSet)

  '--- Connect a datasource to the supplied control
  objControl.DataSource = dstDataSet
  '--- Bind data to control
  objControl.DataBind()

  '--- Close database connection
  conDatabase.Close()
End Sub
This code results in the following error:
Public member 'DataBind' on type 'DataGrid' not found.

I tested with a listbox also and this resulted in the following error:
Public member 'DataBind' on type 'ListBox' not found.

The error occures on the line:
objControl.DataBind()
Could anyone help me with this problem? All help would be greatly appriciated.

Many thanks,

Maurits
Next
Reply
Map
View

Click here to load this message in the networking platform