Ajax|xml
aspx file
<%@ Page language= "C #" autoeventwireup= "true" codefile= "Default.aspx.cs" inherits= "_default"%>
Untitled Page
User name: <% #Eval ("name")%> message time: <% #Eval ("Sdate")%> |
|
message content: <% #Eval ("Couent")%> |
<TR><TD style= "width:306px" > Name<TR><TD style= "WIDTH:306PX; HEIGHT:77PX "> Message content<TR><TD colspan= "2" > < /tr>
CS file
Using System;
Using System.Data;
Using System.Configuration;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
public partial class _default:system.web.ui.page
{
protected void Page_Load (object sender, EventArgs e)
{
if (! Page.IsPostBack)
{
Binddata ();
}
}
private void Binddata ()
{
DataSet ds = new DataSet ();
Ds. READXML (Server.MapPath ("XMLFile.xml"));
Gridview1.datasource = ds;
Gridview1.databind ();
}
protected void Button1_Click (object sender, EventArgs e)
{
DataSet ds = new DataSet ("my");
Ds. READXML (Server.MapPath ("XMLFile.xml"))//Read XML file
DataRow dr = ds. Tables[0]. NewRow ();
dr["name"] = TextBox1.Text.ToString ();
dr["couent"] = TextBox2.Text.ToString ();
dr["sdate"] = DateTime.Now;
Ds. Tables[0]. Rows.Add (DR);
Ds. WriteXml (Server.MapPath ("XMLFile.xml"))//write XML file
Response.Redirect ("default.aspx");
}
protected void Gridview1_pageindexchanging (object sender, Gridviewpageeventargs e)
{
Gridview1.pageindex = E.newpageindex;
Binddata ();
}
}
XML file
xiaoxiao
xiaoxoao
2006-11-14 21:06:14
Download code here Http://www.cnblogs.com/Files/TeaGreen/liuyanbo.rar