【发布时间】:2011-12-17 13:57:51
【问题描述】:
我想在 ASP.net(在 Visual Studio 2010 中)中为 XML 网格视图编写、更新或编辑函数,但我不知道应该使用哪个操作?
这是我的代码,但它不起作用。当我在 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();
}
谢谢
【问题讨论】:
标签: asp.net xml visual-studio-2010