码迷,mamicode.com
首页 > Web开发 > 详细

Devexpress 中如何写ASPxGridView新增修改时的数据验证

时间:2016-01-04 10:17:09      阅读:807      评论:0      收藏:0      [点我收藏+]

标签:

 //验证
        protected void grid_Deptlist_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)
        {
            if (e.NewValues["DEPNAME"] == null)
            {
                AddError(e.Errors, this.grid_Deptlist.Columns["DEPNAME"], "部门名称必填!");
            }

            DataTable dt = new DataTable();
            dt = customerservicebll.DeptList(PEOID).Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {

                if (dt.Rows[i]["DEPNAME"].ToString() == e.NewValues["DEPNAME"].ToString())
                {
                    AddError(e.Errors, this.grid_Deptlist.Columns["DEPNAME"], "对不起,您输入的部门名称已存在!");
                }
            }

         
            if (e.Errors.Count > 0) e.RowError = "请按照错误提示操作。";
        }

//公共验证方法

  void AddError(Dictionary<GridViewColumn, string> errors, GridViewColumn column, string errorText)
  {
    if (errors.ContainsKey(column)) return;
    errors[column] = errorText;
  }

 

 

Devexpress 中如何写ASPxGridView新增修改时的数据验证

标签:

原文地址:http://www.cnblogs.com/dfxyw/p/5097908.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!