I am using ASP.NET C# and have written a page using the XmlDataSource tool to read an xml file and display the data in a GridView. Everything is great when the file is there. However, the xml file is generated every hour and if you happen to connect to the page while the file is being updated (takes about 2 minutes) an error is displayed (because the file is not there). As I am using the built-in tools to connect and read the xml, is there code that I can use to check if the file exists and, if it does not, open the page without the file.
I can see that there is code to do an if exists, however I can not seem to figure out the part "what to do?" to ignore the XMLDataSource tool. Perhaps I can make a label appear that says to come back in a few minutes, but how do I get it to ignore the data reader?
if (!File.Exists(filename))
{
// what to do?
}