改成:
private void Page_Load(object sender, System.EventArgs e)
{
                           if(!IsPostBack)
                           {
string xmlpath=Server.MapPath("diary_data.xml");
dsDiary.ReadXml(xmlpath);
Page.DataBind();
XMLp=new xmlproc(Server.MapPath("diary_data.xml"));
ViewState["editkey"]=1;
                            }
}

解决方案 »

  1.   

    private void btnWrite_Click(object sender, System.EventArgs e)
    {
    string xmlpath=Server.MapPath("diary_data.xml");
    DateTime date=System.DateTime.Today;
    XMLp.NewDiaryItem(date,txtTitle.Text,txtWeather.Text,txtContent.Text);  
                                dsDiary.ReadXml(xmlpath);
    Page.DataBind();
    pnlWrite.Visible=false;
    }
      

  2.   

    private void Page_Load(object sender, System.EventArgs e)
    {
                               if(!IsPostBack)
                               {
    string xmlpath=Server.MapPath("diary_data.xml");
    dsDiary.ReadXml(xmlpath);
    Page.DataBind();
    XMLp=new xmlproc(Server.MapPath("diary_data.xml"));
    ViewState["editkey"]=1;
                                }
    }