View Single Post
  #5 (permalink)  
Old 09-21-2007, 07:21 AM
ccoonen ccoonen is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Location: Wisconsin
Posts: 317
iTrader: (0)
ccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished road
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....
Reply With Quote
The Following User Says Thank You to ccoonen For This Useful Post:
HelloWorld (09-23-2007)