title: How to set a click event for button in repeater control
body: <p>Hi I am doing a social network service using asp.net/c#, I have little problems with accepting friends request. I display those friends request on repeater control, and that repeater control has confirm button and reject bottom. once user press confirm button a sql query will be executed. </p>
  
  <p>This is that sql query  </p>
  
  <pre><code>SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
           conn.Open();
           try
           {
  
  
  
               string inserQuery = "Update [Friendship] Set Friend_Status = 1 WHERE Friend1 ='" + Session["Email"] + "' And Friend2='" + Session["temmp"] + "'";
               SqlCommand commm = new SqlCommand(inserQuery, conn);
               commm.Parameters.AddWithValue("@Friend1", Session["Email"].ToString());
               commm.Parameters.AddWithValue("@Friend2", Session["Temmp"].ToString());
  
  
  
  
               commm.ExecuteNonQuery();
  
  
             //  Label1.Text = Session["Email"].ToString();
  
  
  
      }
  </code></pre>
  
  <p>Session [email] is = User Login email, temmp [email] is = User who sent a friend request.</p>
  
  <p>I don't know how to get temmp[email] to my Friendship table</p>
  
  <p>this is my repeater control code</p>
  
  <pre><code>  &lt;asp:Repeater ID="Repeater3" runat="server"&gt;
          &lt;ItemTemplate&gt;
  
  
      &lt;div style="border-top: thin none #91ADDD; border-bottom: thin none #91ADDD; padding: 10px;  width: 548px; margin-top: 10px; right: 10px; left: 10px; border-left-width: thin; margin-left: 15px; background-color: #F6F6F6; border-left-color: #91ADDD; border-right-color: #91ADDD;"&gt;
              &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
              &lt;asp:Label ID="Label8" runat="server"&gt;&lt;%#Eval("YourName") %&gt;&lt;/asp:Label&gt;
  
              &lt;asp:Label ID="Label9" runat="server" Text="wants to be a friend !!!"&gt;&lt;/asp:Label&gt;
              &lt;br /&gt;
              &lt;div style="width: 58px; height: 40px"&gt;
                  &lt;asp:Image ID="Image2" runat="server" Height="59px" ImageAlign="Top" ImageUrl='&lt;%#Eval("ProfilePicPath") %&gt; ' Width="55px" /&gt;
                  &lt;div style="width: 318px; margin-left: 176px; margin-top: -10px; height: 27px;"&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
      &lt;div style="margin-top: -20px"&gt;
              &lt;asp:Button ID="Confirm" runat="server" style=" margin-left: 250px; margin-top: 11px;" Text="Confirm" Width="98px" CommandName="confirm" /&gt;
              &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
              &lt;asp:Button ID="Reject" runat="server" Text="Reject" Width="98px" /&gt;
      &lt;/div&gt;
  &amp;nbsp;&lt;div style="width: 431px;  margin-left: 65px; margin-top: -60px"&gt;
                  &lt;asp:Label ID="Label6" runat="server" Font-Bold="True" Font-Names="Arial" ForeColor="#3b5998"&gt;&lt;%#Eval("YourName") %&gt; &lt;/asp:Label&gt;
              &lt;/div&gt;
              &lt;div id="status" style=" width: 461px; margin-left: 78px; margin-top: 11px;"&gt;
                  &amp;nbsp;&lt;br /&gt;
                  &lt;asp:LinkButton ID="LinkEmail" runat="server"CommandArgument=
      '&lt;%# Eval("Email") %&gt;' CommandName="mail"&gt;&lt;%#Eval("Email") %&gt;&lt;/asp:LinkButton&gt;        
                  &lt;asp:HiddenField ID="HiddenField1" runat="server"  /&gt;
              &lt;/div&gt;
              &amp;nbsp;
          &lt;/div&gt;
  
   &lt;/ItemTemplate&gt;
      &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>This is i tried code behind code</p>
  
  <pre><code>  private void Repeater3_ItemCommand(object source, RepeaterCommandEventArgs e)
  
   {
       switch (e.CommandName)
       {
           case "mail":
               string emailId = e.CommandArgument.ToString();
               break;
       }
       Session["temmp"] = e.CommandArgument.ToString();
  
       if (e.CommandName == "confirm")
       {
  
  
           SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
           conn.Open();
           try
           {
  
  
  
               string inserQuery = "Update [Friendship] Set Friend_Status = 1 WHERE Friend1 ='" + Session["Email"] + "' And Friend2='" + Session["temmp"] + "'";
               SqlCommand commm = new SqlCommand(inserQuery, conn);
               commm.Parameters.AddWithValue("@Friend1", Session["Email"].ToString());
               commm.Parameters.AddWithValue("@Friend2", Session["Temmp"].ToString());
  
  
  
  
               commm.ExecuteNonQuery();
  
  
             //  Label1.Text = Session["Email"].ToString();
  
  
  
      }
  
   override protected void OnInit(EventArgs e)
   {
       base.OnInit(e);
  
       Repeater3.ItemCommand += new RepeaterCommandEventHandler(Repeater3_ItemCommand);
  
  
   }
  </code></pre>
  
  <p>I only want when someone click confirm button Friendrequest sender's email should be equal to Session[temmp]</p>