An example of a linq statement that takes the first three items in the collection of listitems. I used this example when I was synchronizing different tabs of a website that each had listboxes. One of the tabs had a limit of three selected items:
Protected Sub Page_ListSync(ByVal lstSelected As List(Of ListItem), ByVal lstAvailable As List(Of ListItem))
Try
' just take the first three from selected
Dim liCollection = From li In lstSelected Select li Take 3
lstSelected = liCollection.ToList()
SRBC.RWQMN.SyncListboxes(lstSelectedStations, lstSelected, lstAvailableStations, lstAvailable)
Catch ex As Exception
SRBC.SRBCErrorLogging.LogError(ex, "ctrlStatistics.Page_ListSync")
End Try
End Sub
No comments:
Post a Comment