The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Visual Basic


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: , ,

Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 06-25-2007, 10:01 PM
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: 308
iTrader: (0)
ccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished road
Icon11 VB.NET 2005 Daily Lesson [6.26.07] - Building Bindable Objects

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
Next, say we've built a business object "User" that contains data like first name, last name, phone, email, etc... We would like to call a function
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
Now, because this is a shared (static) method, their is no need to "instantiate" any objects, you can directly call the Method (Function) GetUsers. This binding list we just created is bindable to almost any control you can throw on the form or webpage.

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()
One line of code for a scalable binding list attachable to the majority of web or form controls.... I'd say it's a win-win
Reply With Quote
The Following User Says Thank You to ccoonen For This Useful Post:
HelloWorld (06-25-2007)
  #2 (permalink)  
Old 06-25-2007, 10:37 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
This is great! It seems to me that BindingList that you're talking about here is REALLY similar with Hashtable and Vector in Java I love them too... But, I'm not *in love* with java though lol..

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #3 (permalink)  
Old 06-25-2007, 10:42 PM
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: 308
iTrader: (0)
ccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished road
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
Reply With Quote
  #4 (permalink)  
Old 06-25-2007, 11:01 PM
admin's Avatar
admin admin is offline
PT Admin
Join Date: Jun 2007
Posts: 119
iTrader: (0)
admin has disabled reputation
Update: *Thread title changed as requested* welcome ccoonen

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to admin For This Useful Post:
ccoonen (06-26-2007)
  #5 (permalink)  
Old 06-26-2007, 09:29 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: 308
iTrader: (0)
ccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished road
sweet, thanks buddy!
Reply With Quote
Reply


Thread Tools
Display Modes

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

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



All times are GMT -7. The time now is 03:41 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50