3

I am trying to insert a button column into a datatable but it says that its an error. Any help pleasE?

        ButtonColumn col = new ButtonColumn();
        col.CommandName = "select";
        col.ButtonType = ButtonColumnType.LinkButton;
        col.HeaderText = "Edit";
        dt.Columns.Add(col);
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
user1292656
  • 2,502
  • 20
  • 48
  • 68

2 Answers2

5

Add Buttoncolumn in DataTable its wired ...thats not possible at all...

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

  1. Boolean
  2. Byte
  3. Char
  4. DateTime
  5. Decimal
  6. Double
  7. Int16
  8. Int32
  9. Int64
  10. SByte
  11. Single
  12. String
  13. TimeSpan
  14. UInt16
  15. UInt32
  16. UInt64

Sample code to add coplumn

DataTable workTable = new DataTable("Customers"); 
DataColumn workCol = workTable.Columns.Add("CustID", typeof(Int32));
workCol.AllowDBNull = true;
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
5

You can add a button only on DataGrid not DataTable.

Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
User.Anonymous
  • 1,719
  • 1
  • 28
  • 51