I want to pass only e.Trip of my string.Format to the method referenced in tripChoose. As of now, it tried to pass a string not formatted for the method. If I could just pass the Trip part of the string, it would work. Any suggestions?
private void LoadExpenseListSums()
{
expenseTotalSelect.Items.Clear();
var sortedList=
from e in roster
group e by e.Trip into expenseCollect
select new { Trip = expenseCollect.Key, SumAmount = expenseCollect.Sum(e => e.Amount) };
foreach (var e in sortedList)
tripChoose.Items.Add(string.Format("{0} | ${1}", e.Trip, e.SumAmount));
}
Right, now we actually know what we’re dealing with, I suspect you want something like this:
This makes a few assumptions:
ase,
–
rosteris an in-memory collection: if it’s not, you’ll probably need anAsEnumerablecall before the formatting, to make that happen locally– Anonymous types work with data binding; I’m not sure whether that’s the case, but I’d hope it is
You then use the
SelectedValuemember later on to find the trip ID.