Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 12th, 2006, 03:20 PM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Get all property values of class

I have a collection of objects. I can successfully loop through the collection, and print the value of any property by explicitly stating the property such as obj.ProductGID will print out the value of the current object's ProductGID property.

Looking for a way to print out the values without having to explicitly stating each one. The code below will print the names of the properties, but I don't know how to get the values.

Can anyone help?

Code:
  Dim prop As System.Reflection.PropertyInfo
  For Each prop In obj.GetType.GetProperties()
    Debug.Write(prop.Name & " ^^ ")
  Next prop
  Debug.WriteLine(vbCrLf)


Reply With Quote
  #2 (permalink)  
Old January 12th, 2006, 04:13 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

        Dim prop As System.Reflection.PropertyInfo
        For Each prop In obj.GetType.GetProperties()
            Response.Write(prop.Name & " ^^ " + "<br>")
            Response.Write(prop.GetValue(obj, Nothing) + "<br>") ----To show the value
        Next prop


Jim

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
LockType Property of the RecordSet Class dslagle2 Excel VBA 1 August 22nd, 2007 01:37 PM
Property access from Class within Partial Class zoltac007 C# 2005 0 December 1st, 2006 12:01 AM
Access to a property in the class. AyatKh ASP.NET 1.0 and 1.1 Basics 2 December 18th, 2003 10:25 AM
Project.Class.Property. ? Jstmehr4u3 VB How-To 4 June 11th, 2003 03:10 PM
Project.Class.Property.? Jstmehr4u3 Pro VB 6 2 June 11th, 2003 11:29 AM



All times are GMT -4. The time now is 05:22 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.