判断DataTable某字段是否包含某值

// <summary>
        /// 判断DataTale中判断某个字段中包含某个数据
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="columnName"></param>
        /// <param name="fieldData"></param>
        /// <returns></returns>
        public static Boolean IsColumnIncludeData(DataTable dt, String columnName, string fieldData)
        {
            if(dt==null)
            {
                return false;
            }
            else
            {
                 DataRow[] dataRows = dt.Select(columnName+"='"+fieldData+"'");
                 if (dataRows.Length.Equals(1))
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
            }

        }

 

posted on 2013-09-21 17:06  AlexGeng  阅读(20812)  评论(1编辑  收藏  举报

导航