Hi,
Kindly follow the below steps
Step: 1
You have to get the user id while logged in login page. then, you can store the user id on session object.
session.add("User_Id",txtUserId.Text.ToString().Trim())
Step: 2
After you logged in successfully, you can check the user_id session object is null or not condition. then, you can request database to retrieve the data for the particular user as below
if(session["User_Id"]!=null)
{
string str = System.Configuration.ConfigurationManager.ConnectionStrings["CensusConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(str);
if (con.State == ConnectionState.Closed)
{
con.Open();
}
string @sessionId = System.Web.HttpContext.Current.Session.SessionID;
SqlCommand cmd=new SqlCommand("Select * from ureg where user_id=@user_id", con); cmd.Parameters.AddWithValue("@user_id",session["User_Id"].ToString().Trim());
SqlDataAdapter da=new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
I hope it can be helpful to you