Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 17th, 2008, 10:35 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Albany, NY, USA.
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default Object Data Source class property

I am having difficulty assigning a property to be used in an ObjectDataSource SELECT method. I am able to set the parameters to match my method signature properly with no problem.

However, my method also uses an object public property - it is not part of the method signature. How am I able to set this public property and have it consumed by the method call?

It's like this:

Public Class myClass

Public Property myProp() As String
   Get
       Return m_myProp
   End Get
   Set(ByVal Value As String)
       m_myProp = Value
   End Set
End Property

Public Function GetData(myParam1 as Integer, myParam2 as String) as DataSet
    dim ds as DataSet
    .
    .
    If m_myProp = 1 Then
        'do something
    End If
    .
    return ds
End Function

Is my only option to change the method signature?

Thanks in advance for your comments.
  #2 (permalink)  
Old March 17th, 2008, 11:49 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Take a look here: http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=368 and look at method #3 in particular. It shows you how to create a new instance of your business object, set the necessary properties and then let the ODS figure out the rest.

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
  #3 (permalink)  
Old March 17th, 2008, 11:56 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Albany, NY, USA.
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar-

Funny you mention that. I took a look at it before I posted. I'm still not sure how you tie that OnCreated method to the method call.
  #4 (permalink)  
Old March 17th, 2008, 12:05 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

First you need to write code for the ObjectCreating event of the ODS, like this:
Code:
Protected Sub ObjectDataSource1_ObjectCreating(ByVal sender As Object, _
       ByVal e As System.Web.UI.WebControls.ObjectDataSourceEventArgs) _
       Handles ObjectDataSource1.ObjectCreating
  Dim myInstance As New MyClass()
  myInstance.myProp = "Whatever value you need here"
  e.ObjectInstance = myInstance
End Sub
That way, an instance of your business object is created when the ODS is about to call your method.

Next, within your method, you should be able to retrieve the myProp property (using m_myprop or myProp) and get at the value you set in the ObjectCreating event in the page.

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
  #5 (permalink)  
Old March 17th, 2008, 02:02 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: Albany, NY, USA.
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That did the trick. I can now send my value to the object method.

Dank U Imar
  #6 (permalink)  
Old March 17th, 2008, 03:21 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Graag gedaan... ;)

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Object Data Source parameters nabeelalkaff BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 8 December 10th, 2007 12:34 AM
Object Data Source error shoakat ASP.NET 2.0 Professional 1 June 20th, 2007 05:40 PM
Object Data Source Error abupapa ASP.NET 2.0 Basics 1 June 13th, 2007 05:43 AM
Property access from Class within Partial Class zoltac007 C# 2005 0 December 1st, 2006 01:01 AM
Get all property values of class rrhandle ASP.NET 1.0 and 1.1 Basics 1 January 12th, 2006 05:13 PM



All times are GMT -4. The time now is 09:49 PM.


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