![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: binding, oop, vbnet |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| Ever wonder about the magic behind binding objects to data sources? For example, you can create a strongly typed dataset or build your own datatable object, then fill it with custom data and just bind the data to a gridview control. Well... we make our own bindable objects too in VS 2005 ![]() Start by Importing one of my favorite namespaces ComponentModel Code: Imports System.ComponentModel that get's all users but as a bindable list of users so it could be directly bound to a textbox control. Code: Public Shared Function GetUsers() As BindingList(Of User)
Dim Users As BindingList(Of User)
' Hit the DAL
' Iterate Over All Users
Users.Add(New UserWeJustConstructedFromDBData)
Return Users
End Function Put this method in the actual User Class. To get this item as a data source in your form or aspx page code you would do: Code: Dim Users as BindingList(Of User) = User.GetUsers() ![]() __________________ Day Cares | Golf Courses | Disc Golf Courses | Campgrounds | Ice Rinks | Paintball Fields | Dentists | Plastic Surgeons | Aging Jokes Catholic Churches | Lutheran Churches | Methodist Churches | Episcopal Churches | Clean Jokes |
| The Following User Says Thank You to ccoonen For This Useful Post: | ||
HelloWorld (06-25-2007) | ||
| |
| |||
| Yes, hashtable is another ... actually ... probably my favorite Collection ![]() I do also enjoy that they gave us in the Collections.Specialized the NameValue Collection. I believe it's what the .NET Querystrings are using to store the Name=Value ![]() __________________ Day Cares | Golf Courses | Disc Golf Courses | Campgrounds | Ice Rinks | Paintball Fields | Dentists | Plastic Surgeons | Aging Jokes Catholic Churches | Lutheran Churches | Methodist Churches | Episcopal Churches | Clean Jokes |
| |||
| sweet, thanks buddy! __________________ Day Cares | Golf Courses | Disc Golf Courses | Campgrounds | Ice Rinks | Paintball Fields | Dentists | Plastic Surgeons | Aging Jokes Catholic Churches | Lutheran Churches | Methodist Churches | Episcopal Churches | Clean Jokes |
![]() |
| Thread Tools | |
| Display Modes | |
| |