Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Datagrid population when no data


Message #1 by "Neil Paterson" <Neil.Paterson@t...> on Mon, 3 Sep 2001 15:18:28
I have been looking at one of the examples from the Prof ASP.Net book 

about populating a datagrid from the database.  The example works ok except

when there is no data returned.  In this case an error is returned to the 

effect that the datagrid could not be populated because there was no data!



How can I check that the Datareader has data before calling the DataBind?



I tried using the Read method of the data reader and only if there was 

data did the grid get populated.  Unfortunately this meant that the grid 

was left unchanged.  So if the page was called and data was returned the 

grid was populated ok.  If the parameters were changed and no data was 

returned the grid still displayed the old values!  This begs the question 

is there a way of clearing a grid?



Hope you can help.



Neil

  Return to Index