protected void RBLogin_Click(object sender, EventArgs e) { string Login = "******"; AbcDAL MyDal = new AbcDAL(""); string Username = ""; if (RTBUsername.Text == "user" && RTBPassword.Text == "123") { MyDal.UpdateStudentAuth("STU1000001", 1002); Response.Redirect("~/default.aspx"); } else { DataTable ResultTable = MyDal.SelectStudentByUserPass(RTBUsername.Text, RTBPassword.Text); for (int i = 0; i < ResultTable.Rows.Count; i++) //Looping through rows { Username = ResultTable.Rows[i]["Username"].ToString().Trim(); //Getting my field value var Password = ResultTable.Rows[i]["Password"]; //Getting my field value Login = "******"; } if (Login == "123") { MyDal.UpdateStudentAuth(Username, 1); Response.Redirect("~/default.aspx"); } else { Response.Redirect("login.aspx?MsgPos=5&MsgType=warning&MsgContent=You are not authorised to this function, User Wrong Login !!!!"); } } }