0
我想在ASP.net中编写,更新或编辑XML gridview的函数(在Visual Studio 2010中),但我不知道应该使用哪个操作?编辑ASP.NET中的XML Gridview的函数
这是我的代码,但它不起作用。当我点击GridView的编辑中出现的异常:
private DataSet ds;
DataRow r;
protected void Page_Load(object sender, EventArgs e)
{
ds = new DataSet();
ds.ReadXml(Server.MapPath("../web.config"));
GridView1.DataSource = ds.Tables["user"];
GridView1.DataBind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridView1.EditIndex = e.RowIndex;
GridView1.DataBind();
}
protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
r = ds.Tables["user"].Rows[e.AffectedRows];
r["password"] = FormsAuthentication.HashPasswordForStoringInConfigFile(GridView1.SelectedRow.Cells[1].ToString(), "MD5");
ds.AcceptChanges();
ds.WriteXml(Server.MapPath("web.config"));
GridView1.DataBind();
}
感谢