I have a question regarding a project I am working on at the moment.
I have this code:
var query = from user in dwe.UsersTable
where user.LoginName.Equals(usernameBox.Text) && user.Password.Equals(pwBox.Text)
select user;
if (query.Count() == 1)
{
Session["User"] = usernameBox.Text;
Response.Redirect("Edit.aspx");
}
else
{
LabelError.Text = "Error try again";
}
}
In my "UsersTable" I have a coulmn named "UserID". I want to send the "userID" as a session to the redirected page (Edit.aspx) the userID must equal the result of comparression between Username and password.
you just need to write down
No need to write donw code you have which use Count method instead of this just make use Of
FirstOrDefaultwill give you the result easily.