I am having some trouble figuring out what parameters to pass in my .ToSelectList()
so i can display my results in a dropdown list box. I have two IQueryable
items and i want to display the results together in one dropdown. I don't have to compare and match it is simply grap and display. A sample of how the results look like is:
Teacher
Doctor
Nurse
Engineer
Jack Smith
Tim Jones
Jill Jack
Here is how my code looks so far:
IQueryable<Report_JobResults> jobs=
_jobsReportRepository.summaryGetJob().OrderBy(o=>o.JobName);
IQueryable<Report_nameResult> users =
_nameReportRepository.summaryGetName().OrderBy(n => n.FirstName).The开发者_JAVA百科nBy(
n => n.LastName);
//Here is where i display results into a dropdown box.
view.Results=jobs.Select(o => o.jobId).ToList().Union(users.Select(u => u.userId).ToList()).ToSelectList();
I am not sure what the parameters will be in the .ToSelectList()
Help will be very much appreciated. :)
thanks
You can try
var results = jobs.Select(o => o.jobId).Union(users.Select(u => u.userId))
.Select( i => new SelectListItem
{
Text = i,
Value = i
};
and use results
for in Html.DropDownListFor()
.
精彩评论