I am creating a grid view dynamically and everything works perfect. But i can't seem to add this property in my code behind when i create the DataGrid. Is there something that i need to do in order to allow this?
DataGrid DG = new DataGrid();
DG.ID = "test";
// This doesn't allow me to add this
DG.AutoGenerateEditButton = true;
DG.DataSource = tbl;
DG.DataBind();
I can see that option when i add a grid view to my aspx page, but in code behind i can't seem to add it.
The problem here is you are using the DataGrid
type which does not have a AutoGenerateEditButton
property. That property is present on the GridView
class. If you switch to using a GridView
this code will compile (although it may cause other errors in parts of the code which aren't shown that depended on the type being DataGrid
)