3

我正在尝试将按钮列插入数据表,但它说它是一个错误。请问有什么帮助吗?

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

2 回答 2

5

在 DataTable 中添加 Buttoncolumn 其有线...这根本不可能...

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

  1. 布尔值
  2. 字节
  3. 字符
  4. 约会时间
  5. 十进制
  6. 双倍的
  7. 16
  8. 整数32
  9. 整数64
  10. 字节
  11. 单身的
  12. 细绳
  13. 时间跨度
  14. UInt16
  15. UInt32
  16. UInt64

添加列的示例代码

DataTable workTable = new DataTable("Customers"); 
DataColumn workCol = workTable.Columns.Add("CustID", typeof(Int32));
workCol.AllowDBNull = true;
于 2012-04-11T10:29:24.723 回答
5

您可以在not上添加buttononly 。DataGridDataTable

于 2012-04-11T10:34:00.553 回答