Search code examples
asp.netviewgridfooter

show footer row by default though no records in the grid view in asp.net


all. May this question again added here , so please forgive me . i wanted to express the scenario.

well!

I have an asp.net web application that having the grid view control binding with database to show the records. but. as usual by nature of the grid view control , if there is no records in the database / table then i would show me blank grid. where as i facilitate to user,m he can add, edit,update the record through this grid view. I placed all the text boxes in footer row. but since no records in table it rendering blank grid.

where as i am giving as datasource to grod view is List of users (List<User>).

I want to show this footer row , though there is no records in the database.


Solution

  • You can do one thing. as you said you are using here List then in the function where you are filling the grid check that is your List having any object ? by its count property. if there is zero count the add a object in list. but extend this object with some property with some default value which does not belong from database but belongs from application level. now in your row data bound command check certain constraints against this extended property for current row object.also check type of the row. except footer make visible false the row which satisfy the condition. thats all you will get only footer row there though your database is empty.

    And if you are using the datatable as datasource then add a blank datarow in your datatable. but keep certain constraint to check this is blank row.