示例#1
0
    protected void gv_Users_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)
    {
        e.NewValues["UserID"] = (gv_Users.FindEditFormTemplateControl("txtUserID") as ASPxTextBox).Value;
        String UserID = (e.NewValues["UserID"] == null ? string.Empty : e.NewValues["UserID"].ToString());

        if (UserID == String.Empty)
        {
            throw new Exception("UserID must not be empty!");
        }
        else if (UserSet.checkExist(UserID) == true)
        {
            if (gv_Users.IsNewRowEditing)
            {
                throw new Exception("UserID already exist!");
            }
        }

        e.NewValues["UserName"] = (gv_Users.FindEditFormTemplateControl("txtUserName") as ASPxTextBox).Value;
        String UserName = (e.NewValues["UserName"] == null ? string.Empty : e.NewValues["UserName"].ToString());

        if (UserName == String.Empty)
        {
            throw new Exception("UserName must not be empty!");
        }

        e.NewValues["Password"] = (gv_Users.FindEditFormTemplateControl("txtPassword") as ASPxTextBox).Value;
        String Password = (e.NewValues["Password"] == null ? string.Empty : e.NewValues["Password"].ToString());

        e.NewValues["ConfirmPassword"] = (gv_Users.FindEditFormTemplateControl("txtConfirmPassword") as ASPxTextBox).Value;
        String ConfirmPassword = (e.NewValues["ConfirmPassword"] == null ? string.Empty : e.NewValues["ConfirmPassword"].ToString());

        if (Password == String.Empty)
        {
            throw new Exception("Password must not be empty!");
        }
        else if (Password != ConfirmPassword)
        {
            throw new Exception("Password and Confirm Password not match!");
        }
    }