Add button column to datatable

I am trying to insert button columns in a datatable, but it says this is an error. Any help like it?

        ButtonColumn col = new ButtonColumn();
        col.CommandName = "select";
        col.ButtonType = ButtonColumnType.LinkButton;
        col.HeaderText = "Edit";
        dt.Columns.Add(col);
+3
source share
2 answers

Add a Buttoncolumn to a DataTable in its wired ... it's not possible at all ...

The DataTable DataColumn DataType property supports the following basic .NET Framework data types:

  • Boolean
  • Byte
  • Char
  • Datetime
  • Decimal
  • Double
  • Int16
  • Int32
  • Int64
  • Sbyte
  • Single
  • Line
  • Timepan
  • UInt16
  • UInt32
  • UInt64

Sample code to add coplumn

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

You can add buttononly to DataGridnot DataTable.

+4
source

All Articles