DataTable 创建主键PrimaryKey

  private DataTable SysSource
    {
        set
        {
            HttpContext.Current.Session["SysSource"] = value;
        }
        get
        {
            DataTable dt = (DataTable)HttpContext.Current.Session["SysSource"];           
            if (dt != null)
            {
                DataColumn[] keys = new DataColumn[1];
                keys[0] = dt.Columns["ID"];
                dt.PrimaryKey = keys;  
            }
            return dt;
        }
    }

你可能感兴趣的:(null)