Click here to Skip to main content
Rate this: bad
good
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" 
 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 1-Apr-13 10:37am
ibbou151
Edited 1-Apr-13 10:39am
v2
Comments
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 OriginalGriff 299
1 Maciej Los 295
2 Sergey Alexandrovich Kryukov 205
3 Aajmot Sk 202
4 Sinisa Hajnal 166
0 OriginalGriff 7,760
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,785


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 1 Apr 2013
Copyright © CodeProject, 1999-2014
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