title: Linq group by to create nested listview
body: <p>I need to create a nested listview and found <a href="http://mattberseth.com/blog/2008/01/building_a_grouping_grid_with.html" rel="nofollow noreferrer">a great article</a> on how to do it, but my situation is a bit different. I am a linq newbie and need a little help please :)</p>
  <p>I need to get my data into a format similar in that article to work (on that link above, search for &quot;Configuring the ListView&quot; and see table right above it).</p>
  <p>Here is my data:</p>
  <pre><code>Format    Movie Name    Price
  DVD       Star Wars     12.99
  DVD       Star Wars II  13.99
  Blue-Ray  Star Wars     15.99
  Blue-Ray  Star Wars II  17.99
  </code></pre>
  <p>Here is what I have, which isn't really that close, but it is as far as I could get:</p>
  <pre><code>var MoviesToBuy = from Movie in dtMovieListDetails.AsEnumerable()
                      //join MovieDetails in dtMovieListDetails.AsEnumerable() on (string)Movie[&quot;ID&quot;] equals (string)MovieDetails[&quot;ID&quot;]
                      group Movie by new
                      {
                          Format = Movie[&quot;Format&quot;],
                          Movies = Movie
                      } into grp
  
                      select new
                      {
                          Format = (string)grp.Key.Format,
                          Movies = grp.Key.Movies
                      };
  
          MoviesToBuy = MoviesToBuy.OrderBy(p =&gt; p.Format);
  
          lvwAmazonMovieGroup.DataSource = MoviesToBuy.ToList();
          lvwAmazonMovieGroup.DataBind();
  </code></pre>
  <p>I have 3 specific issues/questions:</p>
  <p>1.) What I have doesn't work. Since my second column in the group equates to all rows, no actual group is created.</p>
  <p>2.) Despite prior issue, I am also getting &quot;Data source is an invalid type.  It must be either an IListSource, IEnumerable, or IDataSource&quot; error. In this case, the Movies column is being created as a DataRow datatype. Not sure if that is what is creating the problem. Can I cast on that field somehow?</p>
  <p>3.) how can I sort on the fields in the movies. I.e. in the end I want the data to be sorted by Format then Movie Name so the nested list view looks like this:</p>
  <pre><code>Blue-Ray
     Star Wars    12.99
     Star Wars II 13.99
  
  DVD
     Star Wars    15.99
     Star Wars II 17.99
  </code></pre>
  <p>Any points are greatly appreciated!</p>
  <p>Thanks in advance,
  Chad</p>