Click here to Skip to main content
15,868,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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" 
 DataSourceID="SqlDataSource1">
 <columns>
 <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" />
 </columns>
 

 <br />

 <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
 ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
 SelectCommand="SELECT * FROM [Blog] WHERE ([StuID] = @StuID)">
 <SelectParameters>
 <asp:SessionParameter Name="StuID" SessionField="StuID" Type="Int32"/>
 </SelectParameters>


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
Updated 1-Apr-13 9:39am
v2
Comments
Deependra Khangarot 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900