(2) viewguestbook. aspx:
<% @ Page Language = "C #" %>
<% @ Import Namespace = "System" %>
<% @ Import Namespace = "System. IO" %>
<% @ Import Namespace = "System. Data" %>
<% -- The above is the required namespace -- %>
<Html>
<Head>
<Title> Welcome to My Guestbook </title>
<Script language = "C #" runat = server>
// Run the script after the page is downloaded.
Public void Page_Load (Object sender, EventArgs e)
{
// Path of the XML file containing all data
// If your path is different from the following, modify
String datafile = "db/guest. xml ";
// Use a Try-Catch block to read information
Try
{
// Create a dataset object
DataSet guestData = new DataSet ();
// Open a FileStream for the database file
FileStream fin;
Fin = new FileStream (Server. MapPath (datafile), FileMode. Open,
FileAccess. Read, FileShare. ReadWrite );
// Read data from the database
GuestData. ReadXml (fin );
Fin. Close ();
// Pay the dataset in the first table to Repeater
MyDataList. DataSource = guestData. Tables [0]. DefaultView;
MyDataList. DataBind ();
}
Catch (Exception edd)
{
// Catch exceptions
Errmess. Text = "cannot read data from XML files. Cause:" + edd. ToString ();
}
}
</Script>
<LINK href = "mystyle.css" type = text/css rel = stylesheet>
</Head>
<Body topmargin = "0" leftmargin = "0" marginwidth = "0" marginheight = "0" rightmargin = "0">
<! -- # Include File = "header. inc" -->
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service