dataGrid转换dataTable
#region dataGrid转换dataTable
/// <summary>
/// dataGrid转换dataTable
/// </summary>
/// <param name="dg">dataGrid</param>
/// <returns>返回dataTable</returns>
public DataTable DT(DataGrid dg)
{
try
{
DataTable dt = null;
if(dg.DataSource is DataView)
{
dt = (dg.DataSource as DataView).Table;
}
else if(dg.DataSource is DataTable)
{
dt = dg.DataSource as DataTable;
}
else if(dg.DataSource is DataSet)
{
dt = (dg.DataSource as DataSet).Tables[0];
}
return dt;
}
catch (System.Exception ex)
{
throw ex;
}
}
#endregion
dataGrid转换dataTable的更多相关文章
- DataGrid绑定DataTable出错
直接用DataGrid.ItemSource = DataTable.DefaultView时会出现以下错误: target element is 'TextBlock' (Name=''); tar ...
- C# 将Excel以文件流转换DataTable
/* *引用 NuGet包 Spire.XLS */ /// <summary> /// Excel帮助类 /// </summary> public class ExcelH ...
- wpf之DataGrid绑定DataTable,其中DataGridComboBoxColumn双向绑定枚举enum
百度了快一天,没结果,除了几个原创的,都是复制粘贴的内容. 不想用别的笨办法,于是脑洞大开,想出了我的办法. 首先是前台代码,与网上的比较类似: xmlns:jz="clr-namespac ...
- List转换DataTable
/// <summary> /// 将泛类型集合List类转换成DataTable /// </summary> /// <param name="list&q ...
- WPF DataGrid使用DataTable为数据源,添加CheckBox列使用Delete删除行的方法
首先将CanUserDeleteRows设置为False, 其次是设置KeyUp事件 并自定义DataGrid.Columns修改如下 <DataGrid x:Name="DG&quo ...
- List<T> 转换 DataTable
public class List2DataTable { public static string GetClassName(Type type) { if (typ ...
- DataRow数组转换DataTable
public DataTable ToDataTable(DataRow[] rows) { if (rows == null || rows.Length == 0) return null; Da ...
- C# DataRow[]转换DataTable
DataTable dt = ... DataRow[] dr = dt.Select("ID=14"); dt = dr.CopyToDataTable();
- c# 将csv文件转换datatable的两种方式。
第一种: public static DataTable csvdatatable(string path) { DataTable dt = new DataTable(); string conn ...
随机推荐
- julia的优化?
julia> function fib1(n) if n==1 return n else return n+fib1(n-1) end end fib1 (generic function w ...
- java io流之字节流
字节流 字节流主要是操作byte类型数据,以byte数组为准,主要操作类就是OutputStream.InputStream 字节输出流:OutputStream OutputStream是整个IO包 ...
- 九宝老师微信小程序开发的过程
- EXISTS语句
通常在我写EXISTS语句时,我会写成IF EXISTS(SELECT TOP(1) 1 FROM XXX),也没细细考究过为什么要这么写,只是隐约认为这样写没有啥问题,那今天就深究下吧! 首先准备测 ...
- 计算软键盘的高度然后确定自定义的View的具体位置
singleTouchView.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayout ...
- HR开发 读取员工工资
1.使用函数读取员工工资. ①数据结构工资结果 DATA: GT_RGDIR TYPE TABLE OF PC261 , GS_RGDIR TYPE PC261 , GT_PAYRESULT TYPE ...
- ubuntu新建用户无法登陆
使用sudo adduser 创建用户,不存在无法登陆问题,如果使用useradd创建用户xx,需要在新建home目录下建立用户目录. 同时,需要修改用户目录的属主,命令:chown xx:xx ...
- CentOS 6.5 RPM包方式安装 Mysql 5.6
1. 下载MySQL 5.6 下载页面:http://dev.mysql.com/downloads/mysql/此处选择“Red Hat Enterprise Linux 6 / Oracle Li ...
- CMakeLists for tesseract
在网上找了很多,直接用都不行,试了半天的到以下的结果. cmake_minimum_required(VERSION 2.8) project( test ) include_directories ...
- shell学习--grep1
一. grep的来源 通过ex编辑器来查找某个字串: :/pattern/p 其中p是打印,包含字符串pattern的第一行将被打印:如果需要打印包含pattern的所有行,可以这样: :/g/pat ...