Asp.net 修改已有数据的DataTable中某列的数据类型
时间:2014-05-10 07:57:11
收藏:0
阅读:570
DataTable dt_PI = new DataTable(); //克隆表结构 dt_PI = ds.Tables[0].Clone(); dt_PI.Columns["FLTFullPercentage"].DataType = typeof(String);//修改【满柜百分比】列的数据类型 foreach (DataRow row in ds.Tables[0].Rows) { DataRow rowNew = dt_PI.NewRow(); foreach (DataColumn col in ds.Tables[0].Columns) { if (col.ColumnName == "FLTFullPercentage") { rowNew["FLTFullPercentage"] = (BaseDBHelper.ConvData.StrToDbl("" + row["FLTFullPercentage"]) * 100).ToString("F3") + "%"; } else if (col.ColumnName == "NumFreightMoney") { rowNew[col.ColumnName] = BaseDBHelper.ConvData.StrToDbl("" + row[col.ColumnName]).ToString("F2"); } else { rowNew[col.ColumnName] = row[col.ColumnName]; } } dt_PI.Rows.Add(rowNew); }
评论(0)