| I'm a big fan of Creating your class, having private setters/public getters and have Static Methods in the class to instantiate and return a list of itself
Like if you had a class Person
imports system.componentmodel
Public Class Person
Private _FirstName as String
Private _LastName as String
Public Property FirstName() as String
.......
.......
Public Sub New(ByRef FirstName as STring, byref LastName as STring)
me.firstname = firstname
me.lastname = lastname
end sub
Public Function GetAllPeople() as BindingList(Of Person)
Dim People as new BindingList(Of Person)
' Hit DB and get Datatable of all people
For each PDR as PeopleDataRow in PeopleDataTable
people.Add(PDR)
Next
return people
end function
end class
This way it's always a 1liner for you objects directly to a control... then just define what matches what
PeopleDropdownList.DataSource = Person.GetAllPeople()
PeopleDropdownList.DisplayMember = "FirstName"
PeopleDropdownList....... = whatever.... |