i have successfully added a label to the node template and populated this with a database field. (using Adding and Editing Templates at Runtime help).
I am trying to add more labels, which i can do, however...
How do i assign another fieldname to this label ?
ie; label1 shows EmailSubject, label2 needs to show EmailFrom, etc..
Thanks
Mark
Heres what i have working so far...
trvEmails.DataSource = myDataTable
trvEmails.DataTextField =
"EmailSubject"
trvEmails.DataBind()
Public Sub InstantiateIn(ByVal container As Control) Implements System.Web.UI.ITemplate.InstantiateIn
Dim lbl As New Label()
lbl.ID =
"Label"
AddHandler lbl.DataBinding, AddressOf lbl_DataBinding
Dim lbl2 As New Label()
lbl2.ID =
"Label2"
AddHandler lbl2.DataBinding, AddressOf lbl2_DataBinding
container.Controls.Add(lbl)
container.Controls.Add(lbl2)
End Sub
Private Sub lbl_DataBinding(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim target As Label = sender
Dim node As RadTreeNode = DirectCast(target.BindingContainer, RadTreeNode)
Dim itemText As String = DirectCast(DataBinder.Eval(node, "Text"), String)
target.Text = itemText
Catch ex As Exception
End Try
End Sub
Private Sub lbl2_DataBinding(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim target As Label = sender
Dim node As RadTreeNode = DirectCast(target.BindingContainer, RadTreeNode)
Dim itemText As String = DirectCast(DataBinder.Eval(node, "Text"), String)
target.Text = itemText
Catch ex As Exception
End Try
End Sub