Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Declaratively configuring ObjectDataSource parameter with UserIdDeclaratively configuring ObjectDataSource parameter with UserId
Previous
 
Next
New Post
2/19/2007 1:06 PM
 
Hi,

I am developing a module which uses an ObjectDataSource to fetch data from another class. The select method requires some parameters, one being the actual DNN UserId. The ObjectDataSource can be configured to automatically bind its parameters values to several sources: Cookie, Control, Form, Profile, QueryString, Session.

I hoped that the Profile object would be filled with the current user data. But unfortunately it is empty. This is probably because DNN uses its own profile classes and ignores the default .NET profile funcionality. Am I correct?

I can always save the UserId to the Session during login or I can set the property programatically but I'd rather avoid unnecessary coding.

Isn't there a way to get the UserId declaratively?

Thanks in advance,
Nuno
 
New Post
2/19/2007 8:27 PM
 

In Super-Fast Super-Easy Module (DAL+)

I use this code

Protected Sub InsertingItem(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles FormView1.ItemInserting

e.Values.Item("UserID") = Entities.Users.UserController.GetCurrentUserInfo.UserID
e.Values.Item("ModuleId") = ModuleId.ToString()
e.Values.Item("ID") = 0

End Sub

It is possible to create a property in your code behind and then display that value declaratively in the .ascx file. However, the ObjectDataSource control allows you to "wire-up" to multlpe events that will provide you greater control in injecting the values.

The code above shows how I am injecting UserID and ModuleId on inserting. Using this method I can inject a different UserID and ModuleID on selecting.

Why would I want to do this? Perhaps I want to allow the current user to see records from another user. I would want to pass one UserID when selecting and a different one when inserting. 



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
2/20/2007 3:33 AM
 

Yes... but this is not clean. A much better way would be to be able to add it declaratively, but unfortunatly the ASP.NET guys didn't think so.

The most you can do is get the page property as a parameter, but as we are dealing with controls this doesn't cut it :(

One more thing... you can try writting your own custom parameter for data source controls (I did), but then Visual Studio doesn't get intelisense for that parameter, and the whole thing doesn't have the right feeling.


bottom line.... you can't declaratively, you can make an effort to make you own parameter (it's not complicated), but the solution which Michael proposes works so...

 


Thanks,
Vladan Strigo
NETMedia

My website: Vladan.Strigo.NET

Vladan.Strigo.NET: Projects
* Advanced VS2005 development approach - BlankModule
* DNN & Microsoft Ajax best practices guidance

Vladan.Strigo.NET: Resources
* Comprehensive list of DNN 4 Module development resources

 
New Post
2/20/2007 5:21 AM
 
Thank you guys! Your post were most helpful. I'll go for AdefWebserver solution. It's good enough for me. I just wanted to be sure I was not making it unnecessarily complex.
 
New Post
2/20/2007 8:02 AM
 
Hi AdefWebServer,

I think I found a problem with what you suggested. I want to use ObjectDataSource's cache but when I turn it, even though I am sending it different parameters, it always displays the same cached dataset. From what I tested this doesn't happen if the parameters are set declaratively.

Do you also have this problem? Is there any workaround?

Thanks,
Nuno
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Declaratively configuring ObjectDataSource parameter with UserIdDeclaratively configuring ObjectDataSource parameter with UserId


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out