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();
}
感謝