zoukankan      html  css  js  c++  java
  • 修改已有数据的DataTable的字段类型

    //将int类型的字段改为string类型          

    DataTable dtResult = new DataTable();
                dtResult = dt.Clone();
                foreach (DataColumn col in dtResult.Columns)
                {
                   col.DataType = typeof(String);
                }
                for (int i = 0; i < dt.Rows.Count ; i++)
                {
                    DataRow rowNew = dtResult.NewRow();
                    for (int j = 0; j < dt.Columns.Count ; j++)
                    {
                            if (Convert.ToInt32(dt.Rows[i][j]) == 0)
                            {
                                rowNew[j] = "不开考";
                            }
                            else if (Convert.ToInt32(dt.Rows[i][j]) == 1)
                            {
                                rowNew[j] = "开考";
                            }             
                    }
                    dtResult.Rows.Add(rowNew);
                }

  • 相关阅读:
    LINUX学习笔记day2
    android 获取正在运行的服务
    android小部件
    android开发_国外论坛
    取消线程
    AlarmManager的使用
    PendingIntent
    SharedPreferences 的使用
    流量监听
    android 异常-access to constructor not allowed
  • 原文地址:https://www.cnblogs.com/hobby0524/p/7122207.html
Copyright © 2011-2022 走看看