<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Deleting an Entity In Custom BindingList</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Deleting an Entity In Custom BindingList</description>
  <pubDate>Wed, 29 Jul 2026 21:26:39 -700</pubDate>
  <lastBuildDate>Wed, 25 May 2011 16:26:03 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=2716</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Deleting an Entity In Custom BindingList : Before deleting an entity, it&amp;#039;s...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2716&amp;PID=10824#10824</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=477" rel="nofollow">ting</a><br /><strong>Subject:</strong> 2716<br /><strong>Posted:</strong> 25-May-2011 at 4:26pm<br /><br />Before deleting an entity, it's good practice to remove it from any bound lists. What happens if you move&nbsp;<i>MyBase.RemoveItem(index)</i> before&nbsp;<i>entityToRemove.EntityAspect.Delete()</i>?<div><br></div>]]>
   </description>
   <pubDate>Wed, 25 May 2011 16:26:03 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2716&amp;PID=10824#10824</guid>
  </item> 
  <item>
   <title>Deleting an Entity In Custom BindingList : I am trying to be clever and creating...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2716&amp;PID=10821#10821</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1151" rel="nofollow">Randar</a><br /><strong>Subject:</strong> 2716<br /><strong>Posted:</strong> 25-May-2011 at 12:53pm<br /><br />I am trying to be clever and creating my own BindingList, which handles the adding/deleting of entity logic.&nbsp; That way, when I bind it to simple UltraGrids (similar to DataGrids), they should delete themselves.&nbsp; See http://www.ideablade.com/forum/forum_posts.asp?TID=2712&amp;title=editable-grid-controls for some additional info.&nbsp; The problem is, whenever I try to delete the entity via the aspect, I get an error I don't really understand.<br><br>Here is the key parts of the code:<br><br><i>''' &lt;summary&gt;<br>''' This class is a wrapper around BindingList, that is incorporated directly into the the EntityManager for new/delete operations.<br>''' &lt;/summary&gt;<br>''' &lt;typeparam name="T"&gt;&lt;/typeparam&gt;<br>Public Class EntityBindingList(Of T)<br>&nbsp;&nbsp;&nbsp; Inherits BindingList(Of T)&nbsp;&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp; ''' &lt;summary&gt;<br>&nbsp;&nbsp;&nbsp; ''' Removes the item at the specified index.<br>&nbsp;&nbsp;&nbsp; ''' &lt;/summary&gt;<br>&nbsp;&nbsp;&nbsp; ''' &lt;param name="index"&gt;The zero-based index of the item to remove.&lt;/param&gt;<br>&nbsp;&nbsp;&nbsp; ''' &lt;exception cref="T:System.NotSupportedException"&gt;You are removing a newly added item and &lt;see cref="P:System.ComponentModel.IBindingList.AllowRemove" /&gt; is set to false. &lt;/exception&gt;<br>&nbsp;&nbsp;&nbsp; Protected Overrides Sub RemoveItem(ByVal index As Integer)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OnRemovingItem(New RemoveItemEventArgs(Me(index)))<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Convert this to a entity so we can access the EntityAspect<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim entityToRemove As Entity = TryCast(Me(index), IdeaBlade.EntityModel.Entity)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Flag the entity to be deleted when the EntityManager is saved<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entityToRemove.EntityAspect.Delete()<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyBase.RemoveItem(index)<br>&nbsp;&nbsp;&nbsp; End Sub<br><br>End Class</i><br><br>When stepping through the code, as soon as I try to call EntityAspect.Delete(), I get "Unable to delete the row: Cannot call BeginEdit() on Deleted entities."&nbsp; Which makes no sense since I can see through the watch window, it is still flagged as "Unchanged".<br><br>I tried to not Delete it, thinking it might change it under the hood, but no luck.&nbsp; <br><br>So what does the error mean?&nbsp; Or even better, how do I fix it?<br>]]>
   </description>
   <pubDate>Wed, 25 May 2011 12:53:43 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2716&amp;PID=10821#10821</guid>
  </item> 
 </channel>
</rss>