Datatable 列expression使用
来源:互联网 发布:网络热词及解释 编辑:程序博客网 时间:2024/06/05 19:10
具体可查询MSDN:http://msdn.microsoft.com/zh-cn/library/system.data.datacolumn.expression(v=vs.80).aspx
http://www.cnblogs.com/XGLSummer/archive/2012/09/03/2668344.html
http://www.360doc.com/content/09/0611/11/15822_3853228.shtml
http://hi.baidu.com/a250152/item/ddf87cf54f1aaa0885d27876
应用如下所示:
View Code
private void CalcColumns()
{
DataTable table = new DataTable ();
// Create the first column.
DataColumn priceColumn = new DataColumn();
priceColumn.DataType = System.Type.GetType("System.Decimal");
priceColumn.ColumnName = "price";
priceColumn.DefaultValue = 50;
// Create the second, calculated, column.
DataColumn taxColumn = new DataColumn();
taxColumn.DataType = System.Type.GetType("System.Decimal");
taxColumn.ColumnName = "tax";
taxColumn.Expression = "price * 0.0862";
// Create third column.
DataColumn totalColumn = new DataColumn();
totalColumn.DataType = System.Type.GetType("System.Decimal");
totalColumn.ColumnName = "total";
totalColumn.Expression = "price + tax";
// Add columns to DataTable.
table.Columns.Add(priceColumn);
table.Columns.Add(taxColumn);
table.Columns.Add(totalColumn);
DataRow row = table.NewRow();
table.Rows.Add(row);
DataView view = new DataView(table);
dataGrid1.DataSource = view;
}
或者: dataDt.Columns.Add(“colName”, System.Type.GetType("System.String"),item.Expression);
注意:对于expression如下形式Col1+Col2,如果Col1为null,则新列也为null,需用IsNull(Col1,'')函数转化下
- Datatable 列expression使用
- DataTable 使用linq方法获得某列分组列表
- DataTable 修改列名
- DataTable添加行、 列
- 获取DataTable列名
- 定义datatable,列
- DataTable 实现列排序
- datatable删除行、列
- 自定义datatable 的列
- 取datatable的列
- datatable 插入列
- DataTable 定义主键列
- datatable怎么添加列
- 删除 修改 datatable 列
- datatable 自定义列
- jQuery Datatable 自定义列
- datatable 列排序
- DataTable 自增列
- CodeForces 245H
- 序
- 用29吋超阔显示器编程是否超爽?
- IOS#UI之UIlabel
- 【每天一道算法题】恍如隔世
- Datatable 列expression使用
- I MISS YOU
- Linux网络编程必看书籍推荐
- hdu 2066 Dijkstra 最短路应用
- select for update与select for nowait
- uva10564
- Practical Netty (2) CS模式下的Echo及String与ChannelBuffer的转化
- Ubuntu 12.04 telnet exit method
- 用post还是用get