MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ListView. Strange Error

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ASPNet
Author Message
shapper



Joined: 08 Aug 2007
Posts: 4

PostPosted: Wed Dec 12, 2007 2:28 pm    Post subject: ListView. Strange Error Reply with quote

Hello,

I have a ListView connected to a LinqDataSource. All records are
showing the right way.

When I click the Delete item on a row I get the following error:
"Cannot remove an entity that has not been attached"

Does anyone has any idea why I am getting this error?

Thanks,
Miguel

Archived from group: microsoft>public>dotnet>framework>aspnet
Back to top
View user's profile Send private message
David Wier



Joined: 30 Oct 2007
Posts: 5

PostPosted: Wed Dec 12, 2007 10:12 pm    Post subject: Re: ListView. Strange Error Reply with quote

Take a look at this, and see if it helps:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2432732&SiteID=1

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup


"shapper" wrote in message @e4g2000hsg.googlegroups.com...
> Hello,
>
> I have a ListView connected to a LinqDataSource. All records are
> showing the right way.
>
> When I click the Delete item on a row I get the following error:
> "Cannot remove an entity that has not been attached"
>
> Does anyone has any idea why I am getting this error?
>
> Thanks,
> Miguel
Back to top
View user's profile Send private message
shapper



Joined: 08 Aug 2007
Posts: 4

PostPosted: Wed Dec 12, 2007 10:18 pm    Post subject: Re: ListView. Strange Error Reply with quote

On Dec 12, 11:12 pm, "David Wier" wrote:
> Take a look at this, and see if it helps:http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2432732&SiteID=1
>
> David Wierhttp://aspnet101.comhttp://iWritePro.com- One click PDF, convert .doc/.rtf/.txt to HTML with no
> bloated markup
>
> "shapper" wrote in message
>
> @e4g2000hsg.googlegroups.com...
>
> > Hello,
>
> > I have a ListView connected to a LinqDataSource. All records are
> > showing the right way.
>
> > When I click the Delete item on a row I get the following error:
> > "Cannot remove an entity that has not been attached"
>
> > Does anyone has any idea why I am getting this error?
>
> > Thanks,
> > Miguel

Hi,

I follow your hint and solved that error and now I have a new one when
I delete a row:
" Exception Details: System.Data.Linq.ChangeConflictException: Row not
found or changed."

Any idea why do I get this error?

Private Sub ldsTags_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles ldsTags.Init
With ldsTags
.ContextTypeName = "MyDbDataContext"
.EnableDelete = True
.EnableInsert = True
.EnableUpdate = True
.ID = "ldsTags"
.TableName = "Tags"
End With
End Sub ' ldsTags_Init

Private Sub ldsTags_Deleting(ByVal sender As Object, ByVal e As
LinqDataSourceDeleteEventArgs) Handles ldsTags.Deleting

Dim tag As Tag = CType(e.OriginalObject, Tag)
Dim database As New MyDbDataContext
database.Tags.Attach(tag)
database.Tags.DeleteOnSubmit(tag)
database.SubmitChanges()

End Sub ' ldsTags_Deleting

Private Sub ldsTags_Selecting(ByVal sender As Object, ByVal e As
LinqDataSourceSelectEventArgs) Handles ldsTags.Selecting
Dim database As New MyDbDataContext
Dim tags = From t In database.Tags _
Select t.TagID, _
t.Text, _
Active = t.FilesTags.Any Or t.ArticlesTags.Any
e.Result = tags
End Sub ' ldsTags_Selecting

' lvTags_Init
Private Sub lvTags_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles lvTags.Init
With lvTags
.DataSourceID = "ldsTags"
.DataKeyNames = New String() {"TagID"}
.ID = "lvTags"
.InsertItemPosition = InsertItemPosition.FirstItem
End With
With lvTags
.EditItemTemplate = New
TagsTemplate(TemplateType.EditItemTemplate)
.EmptyDataTemplate = New
TagsTemplate(TemplateType.EmptyDataTemplate)
.InsertItemTemplate = New
TagsTemplate(TemplateType.InsertItemTemplate)
.ItemTemplate = New TagsTemplate(TemplateType.ItemTemplate)
.LayoutTemplate = New
TagsTemplate(TemplateType.LayoutTemplate)
End With
End Sub ' lvTags_Init

Private Sub lvTags_Load(ByVal sender As Object, ByVal e As
EventArgs) Handles lvTags.Load
lvTags.DataBind()
End Sub ' lvTags_Load

Thanks,
Miguel

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ASPNet All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group