title: Styling a GridView's rows and cells with CSS
body: <p>I want to use CSS to format my GridView rows.</p>
  
  <p>I've set up my GridView in the aspx like so:</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server"&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>I set and bind the data source in the code-behind by calling a method to get my data set from a data access layer. </p>
  
  <p>However, because I set the datasource programmatically, the rows and cells have no id attributes. </p>
  
  <p>How can you use CSS to style and format those rows and cells?</p>
  
  <p>This is the HTML generated currently:</p>
  
  <pre><code>&lt;div&gt;
      &lt;table cellspacing="0" rules="all" border="1" id="ContentPlaceHolderHome_GridView1" style="border-collapse:collapse;"&gt;
          &lt;tr&gt;
              &lt;th scope="col"&gt;Date&lt;/th&gt;&lt;th scope="col"&gt;Project&lt;/th&gt;&lt;th scope="col"&gt;Amount&lt;/th&gt;
          &lt;/tr&gt;&lt;tr&gt;
              &lt;td&gt;1/1/2011 12:00:00 AM&lt;/td&gt;&lt;td&gt;MY COMPANY&lt;/td&gt;&lt;td&gt;1000.99&lt;/td&gt;
          &lt;/tr&gt;&lt;tr&gt;
              &lt;td&gt;2/1/2011 12:00:00 AM&lt;/td&gt;&lt;td&gt;ABC Company&lt;/td&gt;&lt;td&gt;1001.99&lt;/td&gt;
          &lt;/tr&gt;&lt;tr&gt;
              &lt;td&gt;1/3/2011 12:00:00 AM&lt;/td&gt;&lt;td&gt;MY COMPANY&lt;/td&gt;&lt;td&gt;1002.99&lt;/td&gt;
          &lt;/tr&gt;&lt;tr&gt;
              &lt;td&gt;4/1/2011 12:00:00 AM&lt;/td&gt;&lt;td&gt;MY COMPANY&lt;/td&gt;&lt;td&gt;1003.99&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>