At line 1 below, lb.ID may contain lslCity or lstState. Variable filedName
at the same line, therefore, could contain "City" or "State" (field names).
Question: How can I insert filedName
to replace City
at lines 3 and 5 with filedName
I see that filedName
is string not a field type. I do not know how to cast and convert to filed name,
This way, I will be able to use one LINQ string for two controls.
string filedName = lb.ID.Substring(3);
ListItem outputs = (from output in wscgsContext.Searches
group output by output.City into theGroup
select new ListItem(theGroup.FirstOrDefault().City)).ToArray();