C# 在无效用户名或密码的标签框上显示错误

C# 在无效用户名或密码的标签框上显示错误,c#,asp.net,linq-to-entities,C#,Asp.net,Linq To Entities,这是我的密码。如何编写代码标签框。我从两个不同的表中选择数据,每个表将重定向到两个不同的页面。 受保护的无效按钮1\u单击(对象发送者,事件参数e) { var qry=(来自je.employee中的测试) 其中test.emp_email.Equals(TxtUserName.Text)和 test.emp_pass.Equals(TxtPassword.Text) 选择test).FirstOrDefault() 试试这个: var qry = (from test in je.empl

这是我的密码。如何编写代码标签框。我从两个不同的表中选择数据,每个表将重定向到两个不同的页面。 受保护的无效按钮1\u单击(对象发送者,事件参数e) { var qry=(来自je.employee中的测试) 其中test.emp_email.Equals(TxtUserName.Text)和 test.emp_pass.Equals(TxtPassword.Text) 选择test).FirstOrDefault()

试试这个:

var qry = (from test in  je.employee
                  where test.emp_email.Equals(TxtUserName.Text) & test.emp_pass.Equals(TxtPassword.Text)
                   select test).FirstOrDefault();
   var qry2 = (from test1 in je.employer
                    where test1.c_mail.Equals(TxtUserName.Text) & test1.c_pass.Equals(TxtPassword.Text)
                    select test1).FirstOrDefault();
    if (null!=qry)
    {
        Response.Redirect("EmployeeHome.aspx");
    }
    else if(null != qry2)
    {
         Response.Redirect("EmployerHome.aspx");          
    }
    else
    {
        Label1.Text = "Incorrect username or password!";
    }

不,不。登录正常。我问如果登录失败,页面上会出现一个标签框,并提示“无效数据”。如何在这段代码中实现这一点,因为你可以看到我已经使用了其他条件。所以它显示了一个错误。嘿,它只是重定向到EmployeeHome.aspx。EmployeeHome.aspx呢。。?
var qry = (from test in  je.employee
                  where test.emp_email.Equals(TxtUserName.Text) & test.emp_pass.Equals(TxtPassword.Text)
                   select test).FirstOrDefault();
   var qry2 = (from test1 in je.employer
                    where test1.c_mail.Equals(TxtUserName.Text) & test1.c_pass.Equals(TxtPassword.Text)
                    select test1).FirstOrDefault();
    if (null!=qry)
    {
        Response.Redirect("EmployeeHome.aspx");
    }
    else if(null != qry2)
    {
         Response.Redirect("EmployerHome.aspx");          
    }
    else
    {
        Label1.Text = "Incorrect username or password!";
    }