且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在gridview中显示当前记录的用户数据

更新时间:2023-01-27 11:38:45

当用户登录

然后在登录按钮上单击您必须维护会话以存储用户ID

即会话[UserId] =用户ID值;



然后你开始查询select * from user_Table where userid =+ Session [UserId] +;

获得数据集后你必须将值设置为标签控件..





快乐编码。 :)
When User Logged in
then On Login Button Click you have to maintain sessionto store user id
i.e. Session["UserId"] = "User Id Value";

then you fire query "select * from user_Table where userid = "+ Session["UserId"] +"";
After getting Dataset you have to set Values to lables controls..


Happy Coding. :)


试试这个..

try this..
Str = "Your Select Query to get user details as per Session("UserId")";
CMD = new SqlCommand(Str, CON);
ADP = new SqlDataAdapter(CMD);
sADP.Fill(DS, "LOGIN");
if (DS.Tables("LOGIN").Rows.Count == 0) {

    Session["UserID"] = UserID.Text.Trim.ToUpper;
    Session["UserName"] = DS.Tables("LOGIN").Rows(0)("Name").ToString.Trim;
   ......

    Response.Redirect("Your Main Page after login");
}


每当用户从Login.aspx页面重定向到Home.apsx页面时,使用QueryString添加UserID或UserName并访问Home.aspx中的查询字符串



Whenever user is Redirecting from Login.aspx page to Home.apsx page add UserID or UserName with QueryString and access that Query string in Home.aspx

btnLogin_Click(object sender, EventArgs e)
{
    if(Is User valid)
    {
        Response.Redirect("Home.aspx?UserID="+txtUserID.Text+"");
    }
}





希望这对你有用..



Hope this will help for u..