1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data;
- namespace Bowin.Common.Data
- {
- public static class DataRowEx
- {
- /// <summary>
- /// 获取指定列的值,并去掉两端的空格
- /// </summary>
- /// <param name="dr"></param>
- /// <param name="colName">列名</param>
- /// <returns></returns>
- public static string GetValue(this DataRow dr, string colName)
- {
- if (dr != null && dr[colName] != null)
- {
- return dr[colName].ToString().Trim();
- }
- else
- {
- return string.Empty;
- }
- }
- /// <summary>
- /// 获取指定列的值,并去掉两端的空格
- /// </summary>
- /// <param name="dr"></param>
- /// <param name="colName">列的索引</param>
- /// <returns></returns>
- public static string GetValue(this DataRow dr, int index)
- {
- if (dr != null && dr[index] != null)
- {
- return dr[index].ToString().Trim();
- }
- else
- {
- return string.Empty;
- }
- }
- }
- }
|