How can I fill a table with items in a list collection(item: Year), using a two dimensional array? The list collection was populated by an external database using linq queries.
ViewModel
public class TableViewModel
{
public List<MovieViewModel> Movies { get; set; }
public MyViewModel[,] MovieValues { get; set; }
}
public class MyViewModel
{
public string MovieValue { get; set; }
}
public class MovieViewModel
{
public string Id { get; set; }
public string Name { get; set; }
public string Year { get; set; }
}
Controller
TableViewModel item;
item=new TableViewModel();
var AllMuvees = from d in db.MoviesTable
orderby d.Id
group d by d.Rating into M
select M;
List<MovieViewModel> OldMovies;
foreach (var a in M.AllMuvees)
{
OldMovies.Add(new MovieViewModel()
{
Id = g.MovieId.ToString(),
Name =g.MovieName,
Year = g.MovieYear.ToString()
});
}
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
item.MovieValues[i, j] = new MyViewModel()
{ MovieValues = *****
(I need help here: I want to fill this with the Years from OldMovies)};
}
}
return View(item);
Have you tried looking at ListViewItem and then populating a list view?
If not then you can easily use a list of arrays, or even populate it in a foreach loop like bellow?
arrange subItems however your list is set out
then in the form just right click your List View in the form(listOfMovies) and add columns
Sorry if I’ve misunderstood the question but i think this is what you needed?