Lloyd Powell
Lloyd Powell

Reputation: 18790

Adding a DataColumn to a DataTable

How do I go about adding a ButtonColumn to a DataTable.

I am basically using a DataTable as the DataSource of a DataGrid and need to add a ButtonColumn to the DataTable so that when I DataBind it to the DataGrid it all works.

Although when I try

dt.Columns.Add(buttonColumn)

This is not allowed. It has to be a basic DataColumn.

Thanks in advance, I know it's a simple question so shouldn't be hard to answer.

Upvotes: 0

Views: 274

Answers (1)

Brad
Brad

Reputation: 15577

You can't add a ButtonColumn to DataTables. Instead, you add the ButtonColumn to the DataGrid (front side or back side) and define its bind (with the DataField property) to a column in the DataTable.

Upvotes: 3

Related Questions