Click here to Skip to main content
11,721,289 members (83,851 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET VB.NET
I am facing a problem with a small project whose aim is to allow students to communicate with their supervisors whilst they are undertaking their projects. For security purposes, I am using the Membership from Microsoft. I have a STUDENT and STAFF tables that are linked to the ASPNET USERS membership table. The login works fine, and the access to the different folders is restricted accordingly.

Re: Tables STUDENT to BLOG

I need help regarding how to store session variable as StuId, instead of username.

This is the blog page form code:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
 AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="BlogID" 
 <asp:BoundField DataField="BlogID" HeaderText="BlogID" InsertVisible="False" 
 ReadOnly="True" SortExpression="BlogID" />
 <asp:BoundField DataField="BlogDate" HeaderText="BlogDate" 
 SortExpression="BlogDate" />
 <asp:BoundField DataField="BlogDesc" HeaderText="BlogDesc" 
 SortExpression="BlogDesc" />
 <asp:BoundField DataField="StuID" HeaderText="StuID" SortExpression="StuID" />
 <asp:BoundField DataField="BlogTitle" HeaderText="BlogTitle" 
 SortExpression="BlogTitle" />
 <br />
 <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
 ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
 SelectCommand="SELECT * FROM [Blog] WHERE ([StuID] = @StuID)">
 <asp:SessionParameter Name="StuID" SessionField="StuID" Type="Int32"/>

Currently if i use in my code behind my blog page:
Session("UserName") = System.Web.HttpContext.Current.User.Identity.Name
It returns a blank page as username is not part of my student or staff table. I have to run a query to link the userID of both STudent and asp.users to get this right. It becomes problematic if i want to insert in the blog.
Posted 1-Apr-13 9:37am
Edited 1-Apr-13 9:39am
(no name)34.1K
Deependra Khangarot at 2-Apr-13 0:17am
Membership provides a convenient mechanism for storing information per user in a Web application, the design of your application require that additional user information be stored with the user authentication information in the Membership data store. In this case, you would need to build a custom membership provider to store and retrieve the user authentication information and the additional user values in your data store.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 515
1 OriginalGriff 279
2 Mika Wendelius 170
3 F-ES Sitecore 150
4 cyycoish 70
0 Sergey Alexandrovich Kryukov 2,209
1 OriginalGriff 969
2 F-ES Sitecore 660
3 Maciej Los 609
4 Richard MacCutchan 560

Advertise | Privacy | Mobile
Web01 | 2.8.150901.1 | Last Updated 1 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100