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.0Getting the user IDGetting the user ID
Previous
 
Next
New Post
3/9/2008 5:18 AM
 

Hello, I am working on a module that pull data from a sql server 2005 database table. This table contains some information that is tied to the DNN user ID. In my module, I have a GridView control that gets this data from the table using a stored procedure in my database. The stored procedure has an input parameter of UserID.

I am calling this stored procedure using the following code:

<asp:SqlDataSource ID="rebateDB" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>"
    SelectCommand="RT_ViewAllRebates" SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:SessionParameter DefaultValue="0" Name="UserID" SessionField="UserInfo.UserID" Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>

I want to be able to pass in the DNN user ID of the current user so my module will only display the results for that particular user. For the SessionField="", I have tried just using "UserID" but that didn't display any results in my GridView. I tested out the stored procedure using test values for the userID input param in the Configure Data Source wizard in VS2005 and it gave me the results like it is supposed to. So, I guess my question is, what should I use for SessionField so it will pass the integer value of the current user's ID?

Thank you for your help.

 
New Post
3/9/2008 2:28 PM
 

sumit381,

It sounds like you were on the right track --

If your control inherits from PortalModulebase, you should be able to use the PortalModuleBase.UserID property.  Remember to add logic to your code that handles the scenario in which the user is not logged in.

Ian


Software Engineer
Co-Founder, dnnGallery
Stack Overflow: Ian Robinson
Twitter: @irobinson
Linked In: Ian Robinson
 
New Post
3/9/2008 2:47 PM
 

Thank you Ian for your response. I used PortalModuleBase.UserID for the SessionField property, but I still did not receive any records in my GridView that are related to the current logged in user (Note: there should be 1 record that shows for the user that I log in as).

Here is how my ascx page is setup:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ViewRebateDB.ascx.cs" Inherits="DotNetNuke.Modules.ViewRebateDB" Explicit="True"%>

It inherits from DotNetNuke.Modules.ViewRebateDB, so should I set that to Inherits="DotNetNuke.Entities.Modules.PortalModuleBase"?

 

Also here is my ascx.cs code behind:

namespace DotNetNuke.Modules
{
    public partial class ViewRebateDB : DotNetNuke.Entities.Modules.PortalModuleBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {}

    }

}

 
New Post
3/10/2008 9:31 AM
 

Hey sumit381,

The control tag and the codebehind that you pasted both look to be correct. You do not need anything related to PortalModuleBase in your .ascx page and your class properly inherits from PortalModuleBase.  Have you tried setting a break point on the line of code that uses the UserID property to see what the value is at run time?

Take care,

Ian


Software Engineer
Co-Founder, dnnGallery
Stack Overflow: Ian Robinson
Twitter: @irobinson
Linked In: Ian Robinson
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Getting the user IDGetting the user ID


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