Using VS2005
In my webpage am using gridview, In a Gridview values is displaying from the table, if there is no value in the table gridview is displaying only the header, it should display a blank columns
I want to adjust the header font, content font….
Expected Output
Adjust the Header font, content font of the Gridview
Gridview should display the blank column if there is no data
One option is to modify your SQL to always return a row. If you’re executing an SP, you can do a
select count(*)from the table using your where clause, and if that’s zero, do something likeselect '' col1, '' col2 ...and return that.Another option is to check the count of rows return in your code. If you’re using a
DataTableorDataSet, this is easy, as you can look atDataTable.Rows.CountorDataSet.Tables[0].Rows.Countrespectively. If you have none, add a row to the table then bind it to your grid. If you’re binding to a DataReader, you can look at theDataReader.HasRowsproperty.Another option is to extend the DataGrid and add your own “No Rows Available” display mode.
The best option all all depends on your level of experience and the environment in which this code is running.