I have a dropdownlist, ddCourse, which I populate with the following LINQ query:
var db = new DataClasses1DataContext(); ddCourse.DisplayMember = "COURSE_TITLE"; ddCourse.ValueMember = "COURSE_ID"; ddCourse.DataSource = db.COURSE_MASTERs.OrderBy(c => c.COURSE_TITLE) .Select(c => new { c.COURSE_ID, c.COURSE_TITLE }) .ToList();
There is another field in this field that I would like to associate with the COURSE_TITLE field in my selection. So, I would like my choice to look like this:
.Select( c => new {c.COURSE_ID, c.CIN + " " + c.COURSE_TITLE})
The only problem is that this is apparently not the way it was done. I basically want to join c.CIN with c.COURSE_TITLE (and have a place in the middle). Can someone suggest me some pointers on how to do this?
The reason I want to do this is because now the only thing that appears in the drop-down list is the name of the course. I would like the course identifier (CIN) to be combined with it when it is displayed.
EDIT: For clarification, I'm using Linq-to-SQL.
Kevin source share