Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello to all,

I'm using grid view to show data..in asp.net

m doing filteration by using textbox data it's working fine..

but if there is no data found in d datatable thn it shoud display 8lst header text.....rit nw in my case it gose blank,,,so which property i hav to use
Posted

Put some code here - someone may be able to help you then.
 
Share this answer
 
By default the datagrid is binded with the datatable/dataset. Thus if no record is returned from the database, your datatable has no rows present and thus nothing is displayed as a part of the gridvew. This is something as datagrid works.

Now, if you want to display header:
Before binding the the datatable with the gridview - check the row count. If that is zero then add a row explicitly from your side with lets say empty valid values. Now bind this new updated datatable to the gridview. You can see the gridview with headers.

you can even add a some text to the cells of the row if needed -something like 'No Records found' (this will need further code to be written like removing the controls in the cells and adding a text)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900