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 ...
随机推荐
- maven project 更新总是jre-1.5
解决如下: <build> <plugins> <plugin> <groupId>org.apa ...
- HDU 1285 确定比赛名次 拓扑排序模板题
http://acm.hdu.edu.cn/showproblem.php?pid=1285 #include <cstdio> #include <cstdlib> #inc ...
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
在ViewPager中,用Fragment显示页面时,报错: java.lang.IllegalStateException: The specified child already has a pa ...
- eclipse黑色主题
Lennon http://www.cnblogs.com/csulennon/p/4231405.html
- 关于Intent的七大重要属性
在Android 中,Intent用来封装两个Activity之间的调用意图,实现两个Activity之间的跳转,并传递信息. Intent的七大重要属性:ComponentName Action ...
- 又一次的Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat)
~~~~~~~~~~~My problem is here~~~~~~~~~~~~~~~~~~~~~~ Error: Microsoft visual C++ 10.0 is required (un ...
- Oracle循环查询结果集 自定义函数
create or replace function Fun_GetRoleIDList(d_fid char) return varchar is rolelist varchar(2000);b ...
- 计算软键盘的高度然后确定自定义的View的具体位置
singleTouchView.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayout ...
- 浅谈rem、em、px
1.px:像素(Pixel) px是相对长度单位,他是相对于显示器屏幕分辨率而言的 优点:比较稳定.精确 缺点:在浏览器 中放大或者缩小浏览页面,会出现页面混乱的情况. 如下例子: .buttonPX ...
- 非阻塞同步算法实战(二)-BoundlessCyclicBarrier
本人是本文的作者,首发于ifeve(非阻塞同步算法实战(二)-BoundlessCyclicBarrier) 前言 相比上一 篇而言,本文不需要太多的准备知识,但技巧性更强一些.因为分析.设计的过程比 ...