public ActionResult updateisrc()
{
AlbumSongModel s = new AlbumSongModel();
List<mainISRC> listalbum = Class1.GetAllAlbum();
s.listalbum = listalbum.Select(x => new SelectListItem **
{
Value = x.Album.ToString(),
Text = x.Album
});
return View("updateisrc", s);
}
我标记为&#34; **&#34;这行我得错了。请帮帮我
答案 0 :(得分:1)
x本身或x.Album可能为null。试试这个
listalbum.Where(a=>a != null && a.Album != null).Select(x => new SelectListItem
{
Value = x.Album.ToString(),
Text = x.Album
});
希望这会有所帮助。 -Mahesh