Hello,
I have a ListView defined as follows:
Private Sub lv_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles lv.Init
lv.DataKeyNames = New String() {"TagID"}
lv.ID = "lv"
lvTags.ItemTemp late = New MyItemTemplate( )
lvTags.LayoutTe mplate = New MyLayoutTemplat e()
End Sub
Private Sub lv_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles lv.Load
Dim database As New MyContextDataCo ntext
Dim tags = From t In database.Tags _
Select t.TagID, t.Text
lv.DataSource = tags
lv.DataBind()
End Sub
Private Sub lv_ItemDeleting (ByVal sender As Object, ByVal e As
ListViewDeleteE ventArgs) Handles lv.ItemDeleting
Dim database As New MyContextDataCo ntext
Dim tags = From t In database.Tags _
Where t.TagID = New
Guid(lvTags.Dat aKeys(e.ItemInd ex).Value.ToStr ing)
database.Tags.R emove(tags)
End Sub
The ListView displays all records and the ItemDeleting event is fired
but I get an error:
Unable to cast object of type
'System.Data.Li nq.DataQuery`1[Undefined.Data. Linq.Tag]' to type
'Undefined.Data .Linq.Tag'
What am I doing wrong?
Thanks,
Miguel
I have a ListView defined as follows:
Private Sub lv_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles lv.Init
lv.DataKeyNames = New String() {"TagID"}
lv.ID = "lv"
lvTags.ItemTemp late = New MyItemTemplate( )
lvTags.LayoutTe mplate = New MyLayoutTemplat e()
End Sub
Private Sub lv_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles lv.Load
Dim database As New MyContextDataCo ntext
Dim tags = From t In database.Tags _
Select t.TagID, t.Text
lv.DataSource = tags
lv.DataBind()
End Sub
Private Sub lv_ItemDeleting (ByVal sender As Object, ByVal e As
ListViewDeleteE ventArgs) Handles lv.ItemDeleting
Dim database As New MyContextDataCo ntext
Dim tags = From t In database.Tags _
Where t.TagID = New
Guid(lvTags.Dat aKeys(e.ItemInd ex).Value.ToStr ing)
database.Tags.R emove(tags)
End Sub
The ListView displays all records and the ItemDeleting event is fired
but I get an error:
Unable to cast object of type
'System.Data.Li nq.DataQuery`1[Undefined.Data. Linq.Tag]' to type
'Undefined.Data .Linq.Tag'
What am I doing wrong?
Thanks,
Miguel
Comment