title: Binding label inside a gridview from codebehind.
body: <p>I want to bind my totalcomplete variable to lblComplete that is in my gridProgress but i don't know how to do it, can anybody help me out?</p>
  
  <p>ASP Code:</p>
  
  <pre><code>&lt;asp:GridView ID="gridProgress" runat="server" AutoGenerateColumns="False"&gt;
      &lt;Columns&gt;
         &lt;asp:TemplateField HeaderText="Complete"&gt;
            &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" /&gt;
            &lt;HeaderStyle HorizontalAlign="Center" /&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:Label ID="lblComplete" runat="server"&gt;&lt;/asp:Label&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>C# Code:</p>
  
  <pre><code>da = new SqlDataAdapter(sql, oConn);
  da.Fill(ds);
  
  
  //count number of tasks completed, not completed
  int count = ds.Tables[0].Rows.Count;
  string value = ds.Tables[0].Rows[0]["Completed"].ToString();
  int completed = 0;
  for (int i = 0; i &lt; count; i++)
  {
     if (value == "No")
     {
         completed++;
     }                
     int totalcomplete = completed;
     //here i want to bind totalcomplete to my lblCompleted
  }
  </code></pre>