How to pass username to ObjectDataSource as a parameter?

T

timpera2501

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
 
T

timpera2501

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.
 
T

timpera2501

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
 
T

timpera2501

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top