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.