I my applicaiton i'm retriving userID on the login page using login contrarol....
I query the databse for the userID compering the username ...and then adding that to session variable....
I want to use it for sqldatasource to manipulat girdview...but when i load page ...it is blank...i have print useid from session obj on page where i have grid that means userid has been retrived on the page...then why i can't use it in sqldatasource and
grid
# hear is that code that retrive userid from the session
public partial class NewFolder1_report_page : System.Web.UI.Page
{
public static Guid user_id;
protected void Page_Load(object sender, EventArgs e)
{
user_id = (Guid)Session["user_id"];
Response.Write(user_id);
}
}
///////////////////
parthiv.kuba...
Member
110 Points
196 Posts
need advice ...to use session obj in sqldatasource...
Jul 08, 2012 09:28 AM|LINK
hi ...
I my applicaiton i'm retriving userID on the login page using login contrarol....
I query the databse for the userID compering the username ...and then adding that to session variable....
I want to use it for sqldatasource to manipulat girdview...but when i load page ...it is blank...i have print useid from session obj on page where i have grid that means userid has been retrived on the page...then why i can't use it in sqldatasource and grid
public partial class NewFolder1_report_page : System.Web.UI.Page { public static Guid user_id; protected void Page_Load(object sender, EventArgs e) { user_id = (Guid)Session["user_id"]; Response.Write(user_id); } } ///////////////////and page with grid and sqldatasource... <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="report_page.aspx.cs" Inherits="NewFolder1_report_page" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> Report :<br /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="file_id" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField DataField="file_id" HeaderText="file_id" ReadOnly="True" SortExpression="file_id" /> <asp:BoundField DataField="user_id" HeaderText="user_id" SortExpression="user_id" /> <asp:BoundField DataField="file_name" HeaderText="file_name" SortExpression="file_name" /> <asp:BoundField DataField="file_uploadtime" HeaderText="file_uploadtime" SortExpression="file_uploadtime" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:fileshareConnectionString %>" SelectCommand="SELECT [file_id], [user_id], [file_name], [file_uploadtime] FROM [file_upload] WHERE ([user_id] = @user_id)"> <SelectParameters> <asp:SessionParameter Name="user_id" SessionField="suer_id" Type="Object" /> </SelectParameters> </asp:SqlDataSource> </asp:Content>adeelehsan
All-Star
18217 Points
2722 Posts
Re: need advice ...to use session obj in sqldatasource...
Jul 08, 2012 10:43 AM|LINK
Hi
Make sure the session field is spelled correctly. Use the following:
The spellings are wrong
MCPD ASP.NET 4.0 and 3.5, MCTS WSS, MOSS, SharePoint 2010, MCT
Microsoft Community Contributor Award 2011