开发者

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 r开发者_StackOverflow中文版ecords 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.


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.


Here you can read how you can subclass GridView to add the functionality you need: http://mattberseth.com/blog/2007/07/how_to_show_header_and_footer.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜