title: How to populate asp:GridView from code?
body: <p>I have a <code>List&lt;string[]&gt; items</code> list filled with arrays of strings in my code. On the ASPX page, I have added a new grid view control:</p>
  
  <pre><code>&lt;asp:GridView ID="ProductList" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ProductID" EnableViewState="False"&gt;
    &lt;Columns&gt;
      &lt;asp:BoundField DataField="ProductName" HeaderText="Product" SortExpression="ProductName" /&gt;
      &lt;asp:BoundField DataField="CategoryName" HeaderText="Category" ReadOnly="True" SortExpression="CategoryName" /&gt;
      &lt;asp:BoundField DataField="SupplierName" HeaderText="Supplier" ReadOnly="True" SortExpression="SupplierName" /&gt;
      &lt;asp:BoundField DataField="UnitPrice" DataFormatString="{0:C}" HeaderText="Price" HtmlEncode="False" SortExpression="UnitPrice" /&gt;
      &lt;asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued" SortExpression="Discontinued" /&gt;
    &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>I know that I should specify the DataSourceID attribute for the grid view in a fashion similar to this:</p>
  
  <pre><code>&lt;asp:GridView ... `DataSourceID="ObjectDataSource1" ... &gt; 
  &lt;/asp:GridView&gt;
  &lt;asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetProducts" TypeName="ProductsBLL"&gt;
  &lt;/asp:ObjectDataSource&gt;
  </code></pre>
  
  <p>But, I don't know what do <code>OldValuesParameterFormatString</code>, <code>SelectMethod</code> and <code>TypeName</code> attributes represent. Also, I don't have the database to bind to, I just have the list of string arrays named <code>items</code>. Can you help me populate the grid view? It is not necessary to do it through the binding at all. Thanks!</p>