ObjectDataSource Requires Current User ID
ObjectDataSource Requires Current User ID
am 04.01.2008 06:19:14 von Jonathan Wood
I have a page with a GridView, which uses an ObjectDataSource control to
obtain the data.
The ObjectDataSource control calls a static method on a class I've created.
However, this method needs an argument that is the user key of the current
user.
I know how to use GetUser() to get a MembershipUser object and use the
ProviderUserKey property. But how can I get the ObjectDataSource to use
this?
Is there an even that would allow me to set this somehow?
Thanks!
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Re: ObjectDataSource Requires Current User ID
am 04.01.2008 09:59:21 von maciek kanski
Jonathan Wood wrote:
> The ObjectDataSource control calls a static method on a class I've
> created. However, this method needs an argument that is the user key of
> the current user.
wrap existing method with the new one:
public static void YourClass.SelectMethodForObjectDataSource() {
YourClass.ExistingMethod(HttpContext.Current.User.Identity.N ame);
}
and give the YourClass.SelectMethodForObjectDataSource to ObjectDataSource
Re: ObjectDataSource Requires Current User ID
am 05.01.2008 01:04:38 von Jonathan Wood
I guess I didn't think of taking that approach. I was going for a more
generic one that would work with any ID passed. But I could always
overloaded a version that gets the ID from the current user. Thanks.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"maciek kanski" wrote in message
news:477dea73$0$26655$f69f905@mamut2.aster.pl...
> Jonathan Wood wrote:
>> The ObjectDataSource control calls a static method on a class I've
>> created. However, this method needs an argument that is the user key of
>> the current user.
> wrap existing method with the new one:
>
> public static void YourClass.SelectMethodForObjectDataSource() {
> YourClass.ExistingMethod(HttpContext.Current.User.Identity.N ame);
> }
>
> and give the YourClass.SelectMethodForObjectDataSource to ObjectDataSource
Re: ObjectDataSource Requires Current User ID
am 05.01.2008 01:14:02 von Jonathan Wood
Actually, HttpContext.Current.User.Identity.Name won't work because I need
the Membership provider user key.
I can still use GetUser() and get it from there, but I wonder now if that is
the most efficient way of doing that.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"maciek kanski" wrote in message
news:477dea73$0$26655$f69f905@mamut2.aster.pl...
> Jonathan Wood wrote:
>> The ObjectDataSource control calls a static method on a class I've
>> created. However, this method needs an argument that is the user key of
>> the current user.
> wrap existing method with the new one:
>
> public static void YourClass.SelectMethodForObjectDataSource() {
> YourClass.ExistingMethod(HttpContext.Current.User.Identity.N ame);
> }
>
> and give the YourClass.SelectMethodForObjectDataSource to ObjectDataSource
Re: ObjectDataSource Requires Current User ID
am 05.01.2008 02:26:47 von maciek kanski
Jonathan Wood wrote:
> I guess I didn't think of taking that approach. I was going for a more
> generic one that would work with any ID passed.
there is one:
http://msdn2.microsoft.com/en-us/library/57hkzhy5.aspx
ObjectDataSource.SelectParameters
Regards
Re: ObjectDataSource Requires Current User ID
am 05.01.2008 04:59:45 von Jonathan Wood
That's a large page so I could've missed it, but I'm not seeing anything
there where I could use Membership.GetUser().ProviderUserKey as the
argument. Did I miss it?
I think what is needed is an event where I can provide the value, but I
couldn't see an appropriate one.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"maciek kanski" wrote in message
news:477ed1d8$0$26653$f69f905@mamut2.aster.pl...
> Jonathan Wood wrote:
> > I guess I didn't think of taking that approach. I was going for a more
> > generic one that would work with any ID passed.
> there is one:
> http://msdn2.microsoft.com/en-us/library/57hkzhy5.aspx
> ObjectDataSource.SelectParameters
>
> Regards