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 q开发者_开发问答uestion so shouldn't be hard to answer.
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
.
精彩评论