Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > How to pass username to ObjectDataSource as a parameter?

Reply
Thread Tools

How to pass username to ObjectDataSource as a parameter?

 
 
timpera2501
Guest
Posts: n/a
 
      01-19-2006
I have an application where users log in with the standard .NET 2.0 login
control and database.

Once logged in, I want the data retrieved by an ObjectDataSource control to
be dependent on the UserName.

The choices I have for "Parameter Source" are:
Cookie
Control
Form
Profile
QueryString
Session

I have tried putting "UserName" as the parameter name for all of these, but
it still does not pass the variable. How do I reference the username of the
current user and pass it to an ObjectDataSource as a parameter?

Thanks for any help you can offer.
-Amanda
 
Reply With Quote
 
 
 
 
timpera2501
Guest
Posts: n/a
 
      01-19-2006
I have also tried setting the "Parameter Control" to "None" and setting the
default value to "Page.User.Identity.Name.ToString()", but that doesn't work
either.

No errors, but it returns an empty value to SQL server. And I have verified
that the data is flowing correctly from SQL to the app by hardcoding a value
into the SQL query.


"timpera2501" wrote:

> I have an application where users log in with the standard .NET 2.0 login
> control and database.
>
> Once logged in, I want the data retrieved by an ObjectDataSource control to
> be dependent on the UserName.
>
> The choices I have for "Parameter Source" are:
> Cookie
> Control
> Form
> Profile
> QueryString
> Session
>
> I have tried putting "UserName" as the parameter name for all of these, but
> it still does not pass the variable. How do I reference the username of the
> current user and pass it to an ObjectDataSource as a parameter?
>
> Thanks for any help you can offer.
> -Amanda

 
Reply With Quote
 
 
 
 
timpera2501
Guest
Posts: n/a
 
      01-19-2006
OK.. so after further testing, it appears that "Profile.UserName",
"Session.UserName", and "Page.User.Identity.Name" are all null.

How can this be? I'm logged in, and the .NET 2.0 "LoginName" control is
working on the same page.

I'm about ready to tear my hair out. =(

-Amanda

"timpera2501" wrote:

> I have also tried setting the "Parameter Control" to "None" and setting the
> default value to "Page.User.Identity.Name.ToString()", but that doesn't work
> either.
>
> No errors, but it returns an empty value to SQL server. And I have verified
> that the data is flowing correctly from SQL to the app by hardcoding a value
> into the SQL query.
>
>
> "timpera2501" wrote:
>
> > I have an application where users log in with the standard .NET 2.0 login
> > control and database.
> >
> > Once logged in, I want the data retrieved by an ObjectDataSource control to
> > be dependent on the UserName.
> >
> > The choices I have for "Parameter Source" are:
> > Cookie
> > Control
> > Form
> > Profile
> > QueryString
> > Session
> >
> > I have tried putting "UserName" as the parameter name for all of these, but
> > it still does not pass the variable. How do I reference the username of the
> > current user and pass it to an ObjectDataSource as a parameter?
> >
> > Thanks for any help you can offer.
> > -Amanda

 
Reply With Quote
 
timpera2501
Guest
Posts: n/a
 
      01-19-2006
Well, for those who care.. =).. here is what fixed it for me.

Apparently, even tho Profile.UserName is automatically there for every
profile, you still have to put a <profiles> section in your web.config to
enable profiles at all.

I had originally thought that you only added a <profiles> section to your
web.config if you had additional fields you wanted to save info about.

So now, it works with Profile.Username.


"timpera2501" wrote:

> OK.. so after further testing, it appears that "Profile.UserName",
> "Session.UserName", and "Page.User.Identity.Name" are all null.
>
> How can this be? I'm logged in, and the .NET 2.0 "LoginName" control is
> working on the same page.
>
> I'm about ready to tear my hair out. =(
>
> -Amanda
>
> "timpera2501" wrote:
>
> > I have also tried setting the "Parameter Control" to "None" and setting the
> > default value to "Page.User.Identity.Name.ToString()", but that doesn't work
> > either.
> >
> > No errors, but it returns an empty value to SQL server. And I have verified
> > that the data is flowing correctly from SQL to the app by hardcoding a value
> > into the SQL query.
> >
> >
> > "timpera2501" wrote:
> >
> > > I have an application where users log in with the standard .NET 2.0 login
> > > control and database.
> > >
> > > Once logged in, I want the data retrieved by an ObjectDataSource control to
> > > be dependent on the UserName.
> > >
> > > The choices I have for "Parameter Source" are:
> > > Cookie
> > > Control
> > > Form
> > > Profile
> > > QueryString
> > > Session
> > >
> > > I have tried putting "UserName" as the parameter name for all of these, but
> > > it still does not pass the variable. How do I reference the username of the
> > > current user and pass it to an ObjectDataSource as a parameter?
> > >
> > > Thanks for any help you can offer.
> > > -Amanda

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
loginview control displays network username instead of (web) username Shailesh Patel ASP .Net Web Controls 0 11-08-2006 08:19 PM
ObjectDataSource method as another ObjectDataSource David Thielen ASP .Net Web Controls 3 03-23-2006 01:50 AM
Pass UserID instead of Username to other pages after logged on, ASP.NET 2.0 Hardy Wang ASP .Net 1 12-05-2005 07:28 PM
Change the username found in "C:\Documents and Settings\Username" The Reluctant Robot Named Jude Computer Support 1 05-05-2004 07:11 AM



Advertisments