S
shapper
Hello,
I have a ListView as defined as follow:
Private Sub lv_ItemDeleting(ByVal sender As Object, ByVal e As
ListViewDeleteEventArgs) Handles lv.ItemDeleting
Dim database As New TestDataContext
Dim tag As Tag = From t In database.Tags _
Where t.TagID =
lv.DataKeys(e.ItemIndex).Value
database.Tags.Remove(Tag)
End Sub
Private Sub lv_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles lv.Init
lv.DataKeyNames = New String() {"TagID"}
lv.ID = "lv"
lvTags.ItemTemplate = New MyItemTemplate()
lvTags.LayoutTemplate = New MyLayoutTemplate()
End Sub
Private Sub lv_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles lv.Load
Dim database As New TestDataContext
Dim tags = From t In database.Tags _
Select t.TagID, t.Text
lv.DataSource = tags
lv.DataBind()
End Sub
My List View displays the records. However the item is not deleted
when the delete button is fired ...
I debugged it and the ItemDeleting event is fired!
What am I doing wrong?
I also tried with an existing TagId:
Dim tag As Tag = From t In database.Tags _
Where t.TagID = New Guid("5f8f46cc-709c-
dc11-8760-000e35bd65c3")
But I got the error:
Unable to cast object of type 'System.Data.Linq.DataQuery`1[Tag]' to
type 'Tag'.
Please, could someone tell me what I am doing wrong?
I don't know what else to try!
Thanks,
Miguel
I have a ListView as defined as follow:
Private Sub lv_ItemDeleting(ByVal sender As Object, ByVal e As
ListViewDeleteEventArgs) Handles lv.ItemDeleting
Dim database As New TestDataContext
Dim tag As Tag = From t In database.Tags _
Where t.TagID =
lv.DataKeys(e.ItemIndex).Value
database.Tags.Remove(Tag)
End Sub
Private Sub lv_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles lv.Init
lv.DataKeyNames = New String() {"TagID"}
lv.ID = "lv"
lvTags.ItemTemplate = New MyItemTemplate()
lvTags.LayoutTemplate = New MyLayoutTemplate()
End Sub
Private Sub lv_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles lv.Load
Dim database As New TestDataContext
Dim tags = From t In database.Tags _
Select t.TagID, t.Text
lv.DataSource = tags
lv.DataBind()
End Sub
My List View displays the records. However the item is not deleted
when the delete button is fired ...
I debugged it and the ItemDeleting event is fired!
What am I doing wrong?
I also tried with an existing TagId:
Dim tag As Tag = From t In database.Tags _
Where t.TagID = New Guid("5f8f46cc-709c-
dc11-8760-000e35bd65c3")
But I got the error:
Unable to cast object of type 'System.Data.Linq.DataQuery`1[Tag]' to
type 'Tag'.
Please, could someone tell me what I am doing wrong?
I don't know what else to try!
Thanks,
Miguel