List view and SelectedItemTemplate problem "Help"
-
Hi, I am new to .net and i have this maybe silly question. i have this test list view and i want to take a item field and poste it in a label when selected. here is the code.
Protected Sub DepartmentsListView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) MessageLabel.Text = "The key value is " & _ DepartmentsListView.SelectedValue.ToString() & "." Label1.Text = DepartmentsListView.SelectedItemTemplate.InstantiateIn(what else come here?) End Sub
I was looking for info on that, but not luck. thanks for you attention -
Hi, I am new to .net and i have this maybe silly question. i have this test list view and i want to take a item field and poste it in a label when selected. here is the code.
Protected Sub DepartmentsListView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) MessageLabel.Text = "The key value is " & _ DepartmentsListView.SelectedValue.ToString() & "." Label1.Text = DepartmentsListView.SelectedItemTemplate.InstantiateIn(what else come here?) End Sub
I was looking for info on that, but not luck. thanks for you attentionHello! The selectedItemTemplate is only a template of how the item should be displayed. You should write something like this instead: You have to excuse my lack of VB knowledge
Protected Sub DepartmentsListView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
MessageLabel.Text = "The key value is " & _
DepartmentsListView.SelectedValue.ToString() & "."Here comes my non VB skills in hand :)
ListViewDataItem dataItem = DepartmentsListView.Items[DepartmentsListView.SelectedIndex]
Label1.Text = dataItem.FindControl("TheItemField").Text
End Sub
And as i said, i have never written VB so the syntax may be totaly wrong, but hopefuly if will guide you some. and also, i have not tested the code.
Andreas Johansson
IT Professional at Office IT Partner i Norrbotten Sweden
What we don't know. We learn.
What you don't know. We teach -
Hello! The selectedItemTemplate is only a template of how the item should be displayed. You should write something like this instead: You have to excuse my lack of VB knowledge
Protected Sub DepartmentsListView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
MessageLabel.Text = "The key value is " & _
DepartmentsListView.SelectedValue.ToString() & "."Here comes my non VB skills in hand :)
ListViewDataItem dataItem = DepartmentsListView.Items[DepartmentsListView.SelectedIndex]
Label1.Text = dataItem.FindControl("TheItemField").Text
End Sub
And as i said, i have never written VB so the syntax may be totaly wrong, but hopefuly if will guide you some. and also, i have not tested the code.
Andreas Johansson
IT Professional at Office IT Partner i Norrbotten Sweden
What we don't know. We learn.
What you don't know. We teach