asp.net数据库错误无法连接并检查密码?简单的验证器

时间:2012-02-21 16:08:36

标签: c# asp.net database connection-string

bool lozinka() 
{
    int r = GridView1.Rows.Count;
    for (int i = 0; i < r; i++)
    { 
        if(DropDownList1.SelectedItem.Value==GridView1.Rows[i].Cells[2].Text)
            if (TextBox2.Text == GridView1.Rows[i].Cells[3].Text)
            {
                id = GridView1.Rows[i].Cells[2].Text;
                p = Convert.ToInt32(id);
                exit;
            }

    }
    return false;

}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
    if (lozinka())
        args.IsValid = true;
    else
        args.IsValid = false;
}

//这是我尝试检查密码时出错的代码?当我尝试登录时,这是用户名和密码的自定义验证器

1 个答案:

答案 0 :(得分:1)

试试这个

 p=convert.ToInt32(id);
    return true

而不是退出!