0

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.

Brad Hazelnut
  • 1,603
  • 5
  • 21
  • 33
  • Can you explain more what you mean by "can't seem to add it". Is it not showing up at runtime, you're getting an error during compilation, etc ... – JaredPar Aug 24 '13 at 18:07
  • in visual studio, when i try to add that, it comes up as red and doesn't compile, its says that property doesn't exist. I've been doing some research on this, and i found something that says that datatables can't work with that, and that it needs to be a sqldatasource, is it possible to convert a datatable to sqldatasource, if thats really the issue – Brad Hazelnut Aug 24 '13 at 18:15

1 Answers1

0

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)

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
  • you're right, i just switched to gridview and i see the edit button, but how do i control it, in order to be able to edit? – Brad Hazelnut Aug 24 '13 at 18:23