Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将按钮列添加到数据表_C#_C# 4.0_Datatable - Fatal编程技术网

C# 将按钮列添加到数据表

C# 将按钮列添加到数据表,c#,c#-4.0,datatable,C#,C# 4.0,Datatable,我试图在datatable中插入一个按钮列,但它说这是一个错误。需要帮忙吗 ButtonColumn col = new ButtonColumn(); col.CommandName = "select"; col.ButtonType = ButtonColumnType.LinkButton; col.HeaderText = "Edit"; dt.Columns.Add(col); 在DataTable中添

我试图在datatable中插入一个按钮列,但它说这是一个错误。需要帮忙吗

        ButtonColumn col = new ButtonColumn();
        col.CommandName = "select";
        col.ButtonType = ButtonColumnType.LinkButton;
        col.HeaderText = "Edit";
        dt.Columns.Add(col);

在DataTable中添加按钮列其有线…这根本不可能

DataTable DataColumn数据类型属性支持以下基本.NET Framework数据类型:

  • 布尔值
  • 字节
  • 煤焦
  • 日期时间
  • 十进制
  • 双重的
  • Int16
  • Int32
  • Int64
  • 斯拜特
  • 单身
  • 时间跨度
  • UInt16
  • UInt32
  • UInt64
  • 添加共柱的示例代码

    DataTable workTable = new DataTable("Customers"); 
    DataColumn workCol = workTable.Columns.Add("CustID", typeof(Int32));
    workCol.AllowDBNull = true;
    

    只能在
    DataGrid
    而不是
    DataTable
    上添加
    按钮。您确实没有添加到
    datatable
    ,您需要将其添加到datagrid。2.介意分享一下你得到的错误类型或者我们需要猜测吗?如果你得到了你想要的信息,别忘了将答案标记为已接受…我认为OP实际上试图向datagrid数据源添加列的是datatable,所以这就是为什么:)@Reniuz-我正在等待OP端的更新,以便我可以根据它更新我的答案…我找不到了上述列表中的字节[]