System.NotSupportedException: Specified method is not supported(update xml in GridView)

真是没有办法,因为服务器上面不能安装sql2005,现在做一个小的投票系统,只能用xml做数据库了,
今天用xmldatasource绑定GridView,但是xmldatasource和其他的sqldatasource不一样,它不会自动的更改,删除数据,所以只能自己添加方法了,
在用Gridview1_RowUpdated方法时,用了比较差劲的方法终于可以更改行数据了,可是当执行完成时
会出现System.NotSupportedException: Specified method is not supported
查看下面的错误详细信息
[NotSupportedException: 不支持所指定的方法。]
System.Web.UI.DataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +28
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1218
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +853
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +87
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +86
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +153
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +172
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4921
查了一下MSDN,xmldatasourceview.canUpdate的属性值是只读的值false,
看来不能用GridView来更改,删除操作了,后来到网上查
发现了http://forums.asp.net/1140181/ShowPost.aspx
按照上面的做没有搞定
不过新学习了cancel Control event: RemoveHandler GridView1.RowUpdating, AddressOf GridView1_RowUpdating
加入代码里面也没有用
后来只能用效率很低的方法Response.Redirect("self.aspx"),跳转到自己原来的页面
 终于搞定了
真是没有办法
原文地址:https://www.cnblogs.com/xucanzhao/p/358121.html