title: Button Onclick inside a repeater
body: <p>I have created a repeater that gets 3 different values from a webbservice(Name, Surname and Number). Depending on if the Number I receive is 1 or 0 there are 2 buttons that are set Visible= true or false. (btnNumber0 and btnNumber1).</p>
  
  <pre><code>&lt;asp:Repeater ID="rpt1" runat="server" OnItemDataBound="rptHB_ItemDataBound" OnItemCommand="rptHB_ItemCommand"&gt;     
      &lt;ItemTemplate&gt;
          &lt;div&gt;
              &lt;h1 class="click"&gt;
                  &lt;asp:Label ID="lblName" runat="server" Text='&lt;%# DataBinder.Eval(Container.DataItem, "Name").ToString() %&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;asp:Label ID="lblSurname" runat="server" Text='&lt;%# DataBinder.Eval(Container.DataItem, "Surname").ToString() %&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;asp:Label ID="lblNumber" runat="server" Visible="false" Text='&lt;%# DataBinder.Eval(Container.DataItem, "Numer").ToString() %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/h1&gt;
  
              &lt;div class="expand"&gt; 
                  &lt;select id="optColor"&gt;
                      &lt;option&gt;Blue&lt;/option&gt;
                      &lt;option&gt;Red&lt;/option&gt;
                      &lt;option&gt;Yellow&lt;/option&gt;                       
                      &lt;option&gt;Green&lt;/option&gt;
                      &lt;option&gt;Black&lt;/option&gt;
                  &lt;/select&gt;                  
  
                  &lt;asp:Button ID="btnNumber0" runat="server" Text="0"/&gt;
                  &lt;asp:Button ID="btnNumber1" runat="server" Text="1"/&gt;                            
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>The thing i cant get to work is to make a onClick function to my 2 button. Inside the OnCick I want to take the Name and Color(optColor) from the Person I select and send it back to my webbservice. Do i have to use OnItemCommand, if so can you help me? Or is it another way you can do it?</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      GetInfo();
  }
  
  private void GetInfo()
  {
      rpt1.DataSource = client.SendInfo();
      rpt1.DataBind();
  }
  
  private bool Getbutton(string ValueNumber)
  {
      return ValueNumber == "0";
  }
  
  protected void rptHB_ItemDataBound(object sender, RepeaterItemEventArgs e)
  {
      Label lblNewNumber = (Label)e.Item.FindControl("lblNumber");
      Label lblNewName = (Label)e.Item.FindControl("lblName");
      Button btnNewNumber0 = (Button)e.Item.FindControl("btnNumer0");
      Button btnNewNumber1 = (Button)e.Item.FindControl("btnNumber1");
      string Number = lblNewNumber.Text;
      btnNewNumber0.Visible = GetButton(Number);
      btnNewNumber1.Visible = !GetButton(Number);
   }
  
  protected void rptHB_ItemCommand(object source, RepeaterCommandEventArgs e)
  {
      /* ??? */
  }
  </code></pre>