Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
there is a userid in user table and it is primary key and i want to save this userid in session ..
when user upload documnet his/her userid save in documnet table in document table there is userid column ..

how i done this ?/

this is the image of dcoument table it shows me 0 userid

http://i43.tinypic.com/300a82b.png[^]


and here is the code of login.aspx.cs

C#
protected void Btn_Login_Click(object sender, EventArgs e)
       {
          try
           {
            int users = aa.SignIn(txt_username.Value, txt_pass.Value);
               int user_id;
               if (Session["UserID"] != null)
               {
                   user_id = Convert.ToInt32(Session["UserID"].ToString());
               }
                  if (users == 1)
                   {
                       Session["Login2"] = txt_username.Value;

                       Session["UserTypeID"] = users;

                       Response.Redirect("AdminOp.aspx");
                   }
                   else if (users == 2)
                   {
                       //Session["UserID"] = aa.SignIn(txt_username.Value, txt_pass.Value);


                       Session["Login2"] = txt_username.Value;

                       Session["UserTypeID"] = users;

                       Response.Redirect("upload.aspx");
                   }
               }
           catch
           {
               Label8.Text = "Incorrect User Name or Password";
           }
       }
   }
   }

plzz help
Posted
Comments
Diya Ayesa 6-Oct-13 10:51am    
i want to show which user id upload document
Azee 6-Oct-13 11:56am    
Hey there, user is just being logged in in your Btn_login_Click, then how are you getting an ID from the Session: user_id = Convert.ToInt32(Session["UserID"].ToString());?
Diya Ayesa 6-Oct-13 11:59am    
i add in upload.aspx.cs code in load page ............if (Session["UserID"] != null)
{
//Store the value into a variable
int userId = Convert.ToInt32(Session["UserID"]); //you could also use Convert.ToInt32(Session["UserID"]);
}
Azee 6-Oct-13 12:02pm    
If you can get the userid from Session on Upload.aspx, then what is the problem now?
Diya Ayesa 6-Oct-13 12:31pm    
when i upload document and then i check my document table it show me userid 0 ..check image which i posted

plz Create UserId field in document table same as user table .and when u add file than insert userid within Document table (userid in field).and userid you will takes as input from session variable which keeps userid. thankyou
 
Share this answer
 
Comments
Diya Ayesa 6-Oct-13 11:35am    
i also add userid field in document table and in usertable and i also insert userid in sp..this is sp ..

ALTER procedure [dbo].[upload5]
@DocDesciption nvarchar(50),
@DocName nvarchar(50),
@Uploadfile nvarchar(50),
@DocTypeID int,
@DepID int,

@UploadedBy nvarchar(50),
@UserID int
as
insert into DocumentInfo(DocDesciption,DocName,UploadedDate,Uploadfile,DocTypeID,DepID,UploadedBy,UserID )
values(@DocDesciption,@DocName,GETDATE(),@Uploadfile,@DocTypeID,@DepID,@UploadedBy,@UserID )
plz write
if (Session["userid"] != null)//before postback
{
int userId = Convert.ToInt32(Session["UserID"]);//before postback

if (!IsPostBack)
{

}
}
else
{
respone.redirect("login.aspx");
}
 
Share this answer
 

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