问题
I need to load all the rows from the ItemToGroup
table into one field separated with a comma, I can't use String.Join
since I'm using server mode from DevExpress, it loads the data dynamically from the database on demand. And String.Join
only works on generic lists.
I tried this LINQ Statement:
e.QueryableSource = From c In sqlData.ItemStores
Select c.Price, c.Status,
ItemGroupNames = c.ItemToGroups.Select(Function(g) g.ItemGroup.ItemGroupName)
Problem is that in the grid column it shows:
System.Collections.Generic.List`[system.string]
回答1:
If you just want to show your field values in UI then you can use ColumnView.CustomColumnDisplayText event and in this event you can use String.Join
.
Here is example:
Private Sub gridView1_CustomColumnDisplayText(sender As Object, e As CustomColumnDisplayTextEventArgs) Handles gridView1.CustomColumnDisplayText
Dim list = TryCast(e.Value, List(Of String))
If Not list Is Nothing Then
e.DisplayText = String.Join(", ", list)
End If
End Sub
来源:https://stackoverflow.com/questions/32213326/load-values-via-junctions-table