Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Get actual object with ObjectforId

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> borland.public.delphi.modeldrivenarchitecture.eco
View previous topic :: View next topic  
Author Message
Andreas Hansson
Guest





PostPosted: Thu Oct 11, 2007 12:01 pm    Post subject: Get actual object with ObjectforId Reply with quote

I cannot get the actual object when passing Id between pages.

page1:
aSuggestion := StaffSuggestion.Create(EcoSpace);
UpdateDatabase;
DataBind;
Response.Redirect('suggestion_new.aspx?RootId=' +
IdForObject(aSuggestion.AsIObject));

This works just fine

suggestion_new.aspx:
This fails in Page_Load
CurrentStaffSuggestion := ObjectForId(Id) as StaffSuggestion;

I get "Specified cast is not valid"

How do I get the StaffSuggestion object again?

/Andreas
Back to top
Peter Morris
Guest





PostPosted: Thu Oct 11, 2007 12:51 pm    Post subject: Re: Get actual object with ObjectforId Reply with quote

Quote:
IdForObject(aSuggestion.AsIObject));

Here you passed an IObject


Quote:
ObjectForId(Id)

Here you got back an IObject

You need

CurrentStaffSuggestion := ObjectForId(Id).GetValue<StaffSuggestion>;

or

CurrentStaffSuggestion := ObjectForId(Id).AsObject as StaffSuggestion;




Pete
Back to top
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> borland.public.delphi.modeldrivenarchitecture.eco All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group