ListView. Strange Error

S

shapper

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
 
S

shapper

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top