Wrox Programmer Forums
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 12th, 2006, 04:20 PM
Registered User
Join Date: May 2005
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?

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

Old January 12th, 2006, 05:13 PM
Friend of Wrox
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts

        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


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 01:01 AM
Access to a property in the class. AyatKh ASP.NET 1.0 and 1.1 Basics 2 December 18th, 2003 11: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

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.