I am using sqldatasource to populate my GridView which contains a header and a footer. I use the footer to inser a new row in the database. The problem is: when the sqldatasource returns with no data in the database, the GridView is not displayed. Therefore,
I have no way of inserting a new record under this condition.
Can anyone show me how do I keep displaying the GridView with the header and footer even when the sqldatasource returns with no data?
Thanks in advance.
sg2000
good 'ol chicken / egg cyndrome [:)] Personally I would never put my add inside the grid. Now you know why. The only option is to replace the sqlDataSource with a dataTable and maintain a dummy record around to populate the grid. Or logic that create
the dummy record under those circumstances.
Another solution is to place the add button outside the grid. Other than this...
Interesting to note that the grid has no built in functionality for insert at least not button command. It has to be hacked in. Ever wonder why?
Sorry,
aamador:
Thanks for the quick response. Yes, I agree that using GridView to add a record is pain in the neck, and may be not be doable with sqldatasource. However, sqldatasource is so convinient to handle paging and sorting, and using the footer to add data is so
natural and intuitive for the user (as the footer columns are lined up with the grid columns). Well, may be I will abandon this idea and use other method. Thanks.
sg2000
I use the generic list to solve this issue and i publish this solution on my blog check it and if you have and question contact me or reply
http://blog.waleedmohamed.net/2009/04/show-grid-view-header-and-footer-when.html
sg2000
Can anyone show me how do I keep displaying the GridView with the header and footer even when the sqldatasource returns with no data?
Show Header and Footer when records are empty |
http://mattberseth.com/blog/2007/07/how_to_show_header_and_footer.html |
Can't access this ....
http://blog.waleedmohamed.net/2009/04/show-grid-view-header-and-footer-when.html
沒有留言:
張貼留言