{"id":722,"date":"2012-11-07T20:50:13","date_gmt":"2012-11-07T12:50:13","guid":{"rendered":"http:\/\/www.vcoo.cc\/blog\/?p=722"},"modified":"2012-11-07T21:09:30","modified_gmt":"2012-11-07T13:09:30","slug":"datatable-datarow-remove-delete","status":"publish","type":"post","link":"https:\/\/vcoo.cc\/blog\/722\/","title":{"rendered":"DataTable.Rows.Remove()\u548cDelete()\u7684\u533a\u522b"},"content":{"rendered":"<p>\u4e00\u4e2aDataRow\u5bf9\u8c61\u521a\u88ab\u521b\u5efa\u4e4b\u540e\u5176\u72b6\u6001\u662fDetached\uff0c\u662f\u5b64\u7acb\u7684\u4e00\u4e2a\u5b58\u5728\uff0c\u6240\u4ee5\u5efa\u7acb\u4e86DataRow\u4e4b\u540e\u5728DataRow\u4e2d\u7684\u5355\u5143\u586b\u5145\u4e86\u6570\u636e\u540e\u8fd8\u8981\u901a\u8fc7DataTable.Rows.Add(DataRow)\u65b9\u6cd5\u5c06\u6b64DataRow\u6dfb\u52a0\u5230DataTable\uff0cDataRow\u6dfb\u52a0\u5230DataTable\u540e, \u8fd9\u4e2aDataRow\u7684\u72b6\u6001\u5c31\u8f6c\u53d8\u4e3aAdded\u3002<\/p>\n<p>\u5f53\u4fee\u6539\u4e86\u8fd9\u4e2aDataRow\u540e\uff0c\u8fd9\u4e2aDataRow\u72b6\u6001\u8f6c\u4e3aModified\uff0c\u5f53\u7528DataRow.Delete\uff08\uff09\u65b9\u6cd5\u5220\u9664DataRow\u540e\uff0cDataRow\u72b6\u6001\u5c06\u8f6c\u4e3aDeleted\uff0c\u4e0d\u8fc7\u6b64\u884c\u8fd8\u5b58\u5728\u5728DataTable\u4e2d\u7684\uff0c\u53ea\u662f\u72b6\u6001\u6539\u53d8\u4e86\uff0c\u8fd9\u65f6\u7528DataTable.Rows.Count\u67e5\u770b\u884c\u6570\uff0c\u8ddf\u5220\u9664\u524d\u662f\u4e00\u6837\u7684\u3002<\/p>\n<p>\u53ea\u6709\u5728\u8c03\u7528\u4e86DataTable.Remove(DataRow)\u65b9\u6cd5\u540e\uff0c\u6b64DataRow\u624d\u88ab\u4eceDataTable\u79fb\u9664\uff0c\u72b6\u6001\u4e5f\u56de\u590d\u5230Detached\u5b64\u7acb\u72b6\u6001\u3002\u4f46\u5bf9\u4e8e\u8fdc\u7a0b\u7684Remoting\u7684\u6570\u636e\u96c6DataTable.Remove(DataRow)\u65b9\u6cd5\u4e0d\u80fd\u4ece\u6d4b\u8868\u4e2d\u79fb\u51fa\uff1b\u53ea\u80fd\u7528DataRow.Delete\uff08\uff09\u65b9\u6cd5\u52a0 AcceptChanges\uff08\uff09\u65b9\u6cd5<\/p>\n<p>MSDN\u5bf9DataRow.Delete \u65b9\u6cd5\u7684\u89e3\u91ca\uff1a\u5982\u679c\u884c\u7684 RowState \u662f\u201cAdded\u201d\uff0c\u5219\u8be5\u884c\u5c06\u4ece\u8868\u4e2d\u79fb\u9664\u3002\u5728\u4f7f\u7528 Delete \u65b9\u6cd5\u540e\uff0cRowState \u53d8\u6210\u201cDeleted\u201d\u3002\u5728\u60a8\u8c03\u7528 AcceptChanges \u4e4b\u524d\uff0c\u5b83\u4e00\u76f4\u4fdd\u6301\u201c\u5df2\u5220\u9664\u201d\u3002\u53ef\u901a\u8fc7\u8c03\u7528 RejectChanges \u53d6\u6d88\u5220\u9664\u884c\u3002<\/p>\n<p>\u7528Delete(),DataSet\u7684HasChanges()=true;<br \/>\n\u7528Remove(),DataSet\u7684HasChanges()=false;<\/p>\n<p><em>\u6587\u7ae0\u8f6c\u81ea\u7f51\u7edc<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u4e2aDataRow\u5bf9\u8c61\u521a\u88ab\u521b\u5efa\u4e4b\u540e\u5176\u72b6\u6001\u662fDetached\uff0c\u662f\u5b64\u7acb\u7684\u4e00\u4e2a\u5b58\u5728\uff0c\u6240\u4ee5\u5efa\u7acb\u4e86DataRow\u4e4b\u540e\u5728DataRow\u4e2d\u7684\u5355\u5143\u586b\u5145\u4e86\u6570\u636e\u540e\u8fd8\u8981\u901a\u8fc7DataTable.Rows.Add(DataRow)\u65b9\u6cd5\u5c06\u6b64DataRow\u6dfb\u52a0\u5230DataTable\uff0cDataRow\u6dfb\u52a0\u5230DataTable\u540e, \u8fd9\u4e2aDataRow\u7684\u72b6\u6001\u5c31\u8f6c\u53d8\u4e3aAdded\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[195,201,51],"class_list":["post-722","post","type-post","status-publish","format-standard","hentry","category-csharp","tag-csharp-2","tag-dotnet","tag-51","cat-13-id"],"_links":{"self":[{"href":"https:\/\/vcoo.cc\/blog\/wp-json\/wp\/v2\/posts\/722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vcoo.cc\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vcoo.cc\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vcoo.cc\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vcoo.cc\/blog\/wp-json\/wp\/v2\/comments?post=722"}],"version-history":[{"count":0,"href":"https:\/\/vcoo.cc\/blog\/wp-json\/wp\/v2\/posts\/722\/revisions"}],"wp:attachment":[{"href":"https:\/\/vcoo.cc\/blog\/wp-json\/wp\/v2\/media?parent=722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vcoo.cc\/blog\/wp-json\/wp\/v2\/categories?post=722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vcoo.cc\/blog\/wp-json\/wp\/v2\/tags?post=722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}