Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Error: No default member found for type MyClass

Thread Tools

Error: No default member found for type MyClass

Andy Eshtry
Posts: n/a
Dear Friends
I have a urgent problem to solve. I have created a class and its
collection and then bind it to a datagrid but got the following error.
Please help. Thanks in advance. Andy Eshtry

No default member found for type 'clsAgentPostalCode'

Line 44: Dim oAgentPostalCodeCollection As New

Line 45: dgPostalCode.DataSource = oAgentPostalCodeCollection
Line 46: dgPostalCode.DataBind()

----------------------------code in aspx
file ---------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Not Page.IsPostBack Then

dgPostalCode.DataKeyField = "AssignedPostalCodeID"
'dgPostalCode.DataSource = GetPostalCodeList()
Dim oAgentPostalCodeCollection As New
dgPostalCode.DataSource = oAgentPostalCodeCollection

End If
End Sub
--------------------clsAgentPostalCode -------------------------------------

Public Class clsAgentPostalCode
Public mAgentPostalCodeID As Long
Public mAssignedPostalCodeID As Long
Public mAgentID As Long
Public mAssignedPostalCode As String
Private mSelected As Boolean
Private mPrevSelected As Boolean

Public ReadOnly Property AgentPostalCodeID() As Long
Return mAgentPostalCodeID
End Get
End Property

Public ReadOnly Property AgentID() As Long
Return mAgentID
End Get
End Property

Public ReadOnly Property AssignedPostalCode() As String
Return mAssignedPostalCode
End Get
End Property

Public ReadOnly Property AssignedPostalCodeID() As Long
Return mAssignedPostalCodeID
End Get
End Property

Public Sub New(ByVal parAssignedPostalCodeID As Long, ByVal parSelected
As Boolean, _
ByVal parAssignedPostalCode As String, ByVal parAgentPostalCodeID As
Long, ByVal parAgentID

As Long)

mAgentPostalCodeID = parAgentPostalCodeID
mAssignedPostalCodeID = parAssignedPostalCodeID

mAgentID = parAgentID
mSelected = parSelected
mPrevSelected = parSelected
mAssignedPostalCode = parAssignedPostalCode
End Sub

Public Property Selected() As Boolean
Return Selected
End Get
Set(ByVal Value As Boolean)
Selected = Value
End Set
End Property

End Sub
End Class


Imports System.Collections
Public Class clsAgentPostalCodeCollection
Inherits CollectionBase

Public Sub New(ByVal parAgentID As Long)
Dim sConStr As String
Dim oConfSetting As ConfigurationSettings
sConStr = oConfSetting.AppSettings("ConStr").ToString()
Dim Cn As SqlConnection
Dim daPostalCode As SqlDataAdapter
Dim dsPostalCode As New DataSet()
Cn = New SqlConnection(sConStr)

Dim cmdSel As SqlCommand = New
SqlCommand("spAgentAssignedPostalCode", Cn)
cmdSel.CommandType = CommandType.StoredProcedure
cmdSel.Parameters.Add(New SqlParameter("@AgentID", parAgentID))
daPostalCode = New SqlDataAdapter(cmdSel)
daPostalCode.Fill(dsPostalCode, "tblPostalCode")

Dim AgentPostalCodeRow As DataRow
For Each AgentPostalCodeRow In
Dim par1 As Long =
Dim par2 As Boolean = AgentPostalCodeRow.Item("Selected")
Dim par3 As String =
Dim par4 As Long
If Not
IsDBNull(AgentPostalCodeRow.Item("AgentPostalCodeI D")) Then
par4 = AgentPostalCodeRow.Item("AgentPostalCodeID")
par4 = 0
End If
Dim par5 As Long

If Not IsDBNull(AgentPostalCodeRow.Item("ID_Agent")) Then
par5 = AgentPostalCodeRow.Item("ID_Agent")
par5 = 0
End If

Dim AgentPostalCodeItem As New clsAgentPostalCode(par1,
par2, par3, par4, par5)
Catch ex As Exception
Throw ex
End Try

End Sub

Public Sub Add(ByVal AgentPostalCodeItem As clsAgentPostalCode)

End Sub

Public Sub Remove(ByVal index As Integer)

If (index > Count - 1 Or index < 0) Then


End If
End Sub

Public Function Item(ByVal Index As Integer) As clsAgentPostalCode

Return CType(List(Index), clsAgentPostalCode)
End Function

Public ReadOnly Property Length() As Long
Return List.Count
End Get
End Property

Public Function Find(ByVal id As Long) As clsAgentPostalCode
Dim AgentPostalCodeItem As clsAgentPostalCode

For Each AgentPostalCodeItem In InnerList
If AgentPostalCodeItem.AgentPostalCodeID = id Then
Return AgentPostalCodeItem
End If
Return Nothing
End Function

End Class

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
What's difference between f(const MyClass & in) and f(MyClass in) modemer C++ 11 03-21-2005 03:21 PM
No default member found for type "myClass" error, please help Rob ASP .Net Datagrid Control 1 01-14-2005 02:23 PM
Error: No default member found for type MyClass Andy Eshtry ASP .Net 2 02-14-2004 03:12 PM
is there a difference between new MyClass; and new MyClass();? Mario Fratelli C++ 32 12-09-2003 05:23 AM
More new MyClass; vs. new MyClass(); Dave C++ 1 12-08-2003 07:10 PM