Linq to Objects并将结果绑定到gridview

时间:2012-04-03 12:00:02

标签: vb.net linq listview object gridview

我查了很多解决方案,仍然无法弄明白。我是linq的新手,我正在尝试使用该组进行一些分组。

基本上,这是我试图实现的一个样本

Category 1
   Sub Category a, subcategory b, subcateogry c
Category 2
   sub category a, subcategory b

这是我的代码

Dim oManagedAccountsList As ManagedAccountsList = ManagedAccountsManager.GetBrokeredAccounts(Session.Item("StaffId"))
Dim ManagedAccountsByCurrency = From ManagedAccounts In oManagedAccountsList Group By currencyName = ManagedAccounts.CurrencyName Into myManagedAccounts = Group
Dim managedAccountsList As New ManagedAccountsList
For Each currencyName In ManagedAccountsByCurrency

    '    For Each managedAccount In currencyName.myManagedAccounts
    '        Dim oManagedAccount As New i.BusinessObject.ManagedAccounts
    '        oManagedAccount.AccountNumber = managedAccount.AccountNumber
    '        oManagedAccount.AvailableBalance = managedAccount.AvailableBalance
    '        oManagedAccount.ClearedBalance = managedAccount.ClearedBalance
    '        oManagedAccount.UnclearedBalance = managedAccount.UnclearedBalance
    '        oManagedAccount.LedgerBalance = managedAccount.LedgerBalance
    '        oManagedAccount.DateOpened = managedAccount.DateOpened
    '        oManagedAccountsList.Add(oManagedAccount)
    '    Next

Next

grvBrokeredAccounts.DataSource = ManagedAccountsByCurrency.ToList
grvBrokeredAccounts.DataBind()

这只是给我标题而没有列表项。

如何将标题和列表项分组?

这就是我想要实现的目标

**Currency Name(GBP)    Balances**
Account Customer Name   Opened  Cleared Uncleared Available Ledger
012345  My First Name   My Date 0.00    200.00  500.00  0.00
023891  Dominic Jackson My Date 0.00    1000.00 2500.00 20.00
**CurrencyName(EUR) Balances**
Account Customer Name   Opened  Cleared Uncleared Available Ledger
98765   My Second Name  My Date 10.00   200.00  500.00  30.00
87777   Reggie John 20-mar-2012 200.00  5000.00 20.00   30.00   

0 个答案:

没有答案