I have a select that takes UserName as value and FirstName + LastName as Text. User is not required to enter first and last namem so I want the select to show UserName (which is the email use for registration) if FirstName and LastName are empty. I tried the below variant but is not working properly, it either gives only UserName for all or empty spaces
MemberList = await _context.UsersData.Where(s => s.OrgID == orgid).Select(s => new SelectListItem { Value = s.UserName, Text = s.FirstName + " " + s.LastName == null ? s.UserName : s.FirstName + " " + s.LastName }).ToListAsync();