Something must have happened when i copied the code coz i only used the Member_Login class. It still gives me the same problem.
Is there another way to structure my foreach so it that it only returns the correct value without returning multiple error messages.
Member_Login objM = new Member_Login();
List<member_login> objList = new List<member_login>();
objList = objM.Get_Member_Details();
foreach (Member_Login M in objList)
{
if (txtUsername.Text == M.Username && txtPassword.Text == M.Password)
{
lblresult.Text = M.Member_Id.ToString();
Session["Memid"] = M.Member_Id.ToString();
Response.Redirect("Home.aspx");
}
else
{
MessageBox.Show("You are not found as a registered member", "Error!! Invalid Account", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
</member_login></member_login>
Edit: Code formatted