All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
Ajax+GridView+Xml的简易留言薄_.net资料_编程技术

Writer: aaa Article type: Programming skills(编程技巧) Time: 2013/12/13 9:38:44 Browse times: 459 Comment times: 0

Ajax+GridView+Xml的简易留言薄_.net资料_编程技术


Head photo

Go homepage
Upload pictures
Write articles

Ajax+GridView+Xml的简易留言薄_.net资料_编程技术-你的首页-uuhomepage.com

aspx文件
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
http://www.w3.org/1999/xhtml">

无标题页


















用户姓名:<%#Eval("name") %>留言时间:<%#Eval("sdate")%>



留言内容:<%#Eval("couent")%>








&nbsp; &nbsp;&nbsp;



姓名

留言内容









cs文件
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"));//读取xml文件
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"));//写入xml文件
Response.Redirect("default.aspx");

}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
BindData();
}
}
xml文件



xiaoxiao
xiaoxoao
2006-11-14 21:06:14


在此下载代码http://www.cnblogs.com/Files/TeaGreen/liuyanbo.rar






There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.