标签:
#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
标签:
原文地址:http://www.cnblogs.com/buy0769/p/4588480.html