I have this page with a GridView control inside that’s bound to database. GridView has a command row for insert, delete and updating. The problem is that, since my database table is initially empty, I see an empty grid. I don’t even see the command row in order to be able to insert anything into it.
I managed to solve this by checking for GridView row count and changing its display to InsertTemplate. But I’m wondering if there’s a standard way of doing this, may it already has such functionality?
The same problem with DetailView.
Thanks
I have this page with a GridView control inside that’s bound to database. GridView
Share
You can use the EmptyDataTemplate to handle inserting a new item if the grid’s data source is initially empty.
Define your grid in the ASPX as follows:
A collection of Customer objects is used as the datasource for the grid.
Bind the grid to a data source (empty for this example).
You can then handle the Add and EmptyAdd command in the grid_RowCommand event handler.