http://blog.csdn.net/shuizhaoshui/article/details/51425527 在.NET开发中,操作关系型数据库提取数据经常用到DataTable.ASP.NET前后台数据绑定应用DataTable的时候似乎也很多,但是List集合比DataTable应用更加广泛,提取处理数据也更加方便,MVC绑定数据更倾向于List. 因此,我们会经常需要对List集合和DataTable数据进行互转,以下三个方法是实现List和DataTable互转,以及DataTa…
1.DataTable转List集合 /// <summary> /// DataTable转化为List集合 /// </summary> /// <typeparam name="T">实体对象</typeparam> /// <param name="dt">datatable表</param> /// <param name="isStoreDB">是否存…
//遍历XML 获得 DataSet //XmlTextReader static void Main(string[] args) { string xmlData = @"D:\study\XMLtest\XMLtest\bin\Debug\bookstore.xml"; DataSet t = ConvertXMLToDataSet(xmlData); Console.WriteLine(t); } private static DataSet ConvertXMLToDataS…
public static string JsonParse(OleDbDataReader dataReader) //DataRead转json { StringBuilder jsonString = new StringBuilder(); jsonString.Append("["); while (dataReader.Read()) { jsonString.Append("{"); ; i < dataReader.FieldCount; i+…
public static class ExtensionMethods{/// <summary>/// 将List转换成DataTable/// </summary>/// <typeparam name="T"></typeparam>/// <param name="data"></param>/// <returns></returns>public stati…
/// <summary> /// 打开dbf表 /// </summary> /// <param name="pathName"></param> /// <param name="tableName"></param> /// <returns></returns> public static ITable OpenTable(string pathName, st…
/// <summary> /// List转换为DataTable对象 /// </summary> public class ListTranTableModel { /// <summary> /// 新增的列名称 /// </summary> public string addColumName { get; set; } /// <summary> /// 新增列的默认信息 /// </summary> public Tab…
首先我们看看 Newtonsoft.Json.JsonConvert 是怎么完成的: DataTable table = new DataTable(); table.Columns.Add("id"); table.Columns.Add("name"); table.Columns.Add("url"); table.Rows.Add(", "zhengdjin", "http://blog.csdn.…
1.DataTable转XML #region DataTableToXml /// <summary> /// 将DataTable对象转换成XML字符串 /// </summary> /// <param name="ds">DataSet对象</param> /// <returns>XML字符串</returns> public static string DataTableToXml(DataTable…
1.DataTable转成ListView: 先遍历DataTable的列,把DataTable列名添加到listView列头. 然后外循环添加行,内循环添加列 跟这篇文章是一样的 http://www.cnblogs.com/Sukie-s-home/p/5702469.html 2.ListView转成DataTable: 先遍历ListView的列,把ListView列头添加到DataTable列名. 然后外循环添加行,内循环添加列 items[i].subitems[j].text pu…