This is a migrated thread and some comments may be shown as answers.

[Solved] Set treeview item content issues

1 Answer 115 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Donna Stewart
Top achievements
Rank 1
Donna Stewart asked on 14 Mar 2011, 10:46 PM
I am having all kinds of weird issues when I try to set the content on my treeview item.  Using this -child.Content = Function() %><ul><li><%Response.Write(reportType.taskInfo)</li></ul><% I get Multiline lambda expression is missing 'End Function'.   If I add End Function, it gets really weird - the code gets pushed way out with part of it overwriting the End Function and I get the compilation warning  Function '<anonymous method>' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.  And things just do not work very well.  Since this is VB, should I be coding this differently?  I am using VB.NET 10...  Thank you in advance for your help.

Here's the treeview:
<%= Html.Telerik().TreeView().Name("ReportGroups").ShowCheckBox(True).HtmlAttributes(New With {.style = "font-size:1em; height:550px;"}) _
                              .ClientEvents(Function(evt) evt.OnSelect("getReports")) _
                              .ClientEvents(Function(evt) evt.OnLoad("setContextMenu")) _
                              .ClientEvents(Function(evt) evt.OnDataBound("onTreeViewLoad")) _
                              .ClientEvents(Function(evt) evt.OnCollapse("updateTreeViewState")) _
                              .ClientEvents(Function(evt) evt.OnExpand("updateTreeViewState")) _
                              .BindTo(CType(Model.reportGroupNames, IEnumerable(Of ReportTreeModel)),
                                 Sub(mappings)
                                     mappings.For(Of ReportTreeModel)(
                                     Sub(binding)
                                         binding _
                                             .ItemDataBound(
                                                 Sub(item, rpt)
                                                     Dim isExpanded As Boolean = DirectCast(ViewData("ReportExpandedNodes"), String()).Contains(rpt.reportGroupNameKey)
                                                     If isExpanded Then
                                                         item.Text = "<span class='expanded'></span>" + rpt.reportGroupName
                                                     Else
                                                         item.Text = rpt.reportGroupName
                                                     End If
                                                     item.Value = rpt.reportGroupNameKey
                                                     item.Encoded = False
                                                     item.LoadOnDemand = False
                                                 End Sub)
                                         binding.Children(Function(rpt) rpt.reportUserGroups)
                                     End Sub)
                                     mappings.For(Of ReportUserGroupModel)(
                                     Sub(binding)
                                         binding _
                                             .ItemDataBound(
                                                 Sub(child, userGroup)
                                                     child.Text = userGroup.userGroupName
                                                     child.Value = userGroup.userGroupNameKey
                                                     child.LoadOnDemand = False
                                                     child.Encoded = False
                                                 End Sub)
                                         binding.Children(Function(userGroup) userGroup.reportTypes)
                                     End Sub)
                                     mappings.For(Of UserGroupReportType)(
                                     Sub(binding)
                                         binding _
                                             .ItemDataBound(
                                                 Sub(child, reportType)
                                                     child.Text = reportType.resourceType + " - " + reportType.fileType
                                                     child.Value = reportType.webPermissionsKey
                                                     child.Content = Function() %><ul><li><%Response.Write(reportType.taskInfo)%></li></ul><%
                                                 End Sub)
                                     End Sub)
                                 End Sub)

1 Answer, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 15 Mar 2011, 10:42 AM
Hello Donna,

The question has more to do with VB as a language rather than the Telerik extensions. You should be able to get more precise responses from a dedicated forum, such as the VB Language Forum at MSDN.

That said, I think the problem is that you're declaring the lambda expression as a Function and you don't actually return anything. Try using Sub instead

child.Content = Sub() %><ul><li><%Response.Write(reportType.taskInfo)%></li></ul><% End Sub

I hope this helps.

Best regards,

Tsvetomir Tsonev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
TreeView
Asked by
Donna Stewart
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or