title: ASP.NET Gridview control how to display query data?
body: <p>I have a problem about Gridview control show values; I want to sum duplicated values from three columns from one table and then put the final result to Fridview cells. But the data can't be shown on the Gridview, however I test the sql command in my sql management studio It works well, anyone can help me to solve it? Thanks! </p>
  
  <p>My table name is <strong>[Assessment]</strong>; 
  the all columns are:<strong>[assessmentID],[workstation],[Date].....[numberOfhigh],[numberOffurther],[numberOflow].</strong> 
  <br/> <br/> Now I use " <strong>SELECT SUM(numberOfhigh),SUM(numberOffurther),SUM(numberOflow) FROM Assessment GROUP BY workstation HAVING COUNT(*) > 1</strong> " in order to get duplicated workstations total risk.</p>
  
  <p>front end code:</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server" style="margin-left: 318px" AutoGenerateColumns="False" Height="269px" Width="440px" &gt;
          &lt;Columns&gt;
  
             &lt;asp:BoundField HeaderText="High Risk"  DataField="high"&gt;           
              &lt;ItemStyle BackColor="Red" /&gt;             
              &lt;/asp:BoundField&gt;
  
               &lt;asp:BoundField HeaderText="Further Risk" DataField="further"&gt;             
              &lt;ItemStyle BackColor="#CCCCCC" /&gt;            
              &lt;/asp:BoundField&gt;
  
                &lt;asp:BoundField HeaderText="Low Risk" DataField="low"&gt;              
              &lt;ItemStyle BackColor="#33CC33" /&gt;            
              &lt;/asp:BoundField&gt;
  
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Back end code:</p>
  
  <pre><code>  if (DropDownList2.SelectedIndex == 2 &amp;&amp; DropDownList1.SelectedIndex == 1)
              {
  
                  sqlConn.Open();
  
                  string cmdText = "SELECT SUM(numberOfhigh),SUM(numberOffurther),SUM(numberOflow) FROM Assessment GROUP BY workstation HAVING COUNT(*) &gt; 1";
                  SqlDataAdapter sda = new SqlDataAdapter(cmdText, sqlConn);
                  DataSet ds = new DataSet();
                  sda.Fill(ds);
                  GridView1.DataSource = ds.Tables[0];
                  GridView1.DataBind();
  
  
                  sqlConn.Close();
              }
  </code></pre>