I have tried everything but this button just does not execute


Can someone please help with this.

I have a major issue and cant seem to work out where the problem is. Basically i have an update panel which i keep to visible=false and only show the contents of it when the user is logged in. Now inside it i have a repeater control which outputs user comments.

This is my code below:-

.aspx file

<asp:UpdatePanel ID="UpdatePanel2" runat="server" Visible="false">
      <!-- start parent repeater -->
  <asp:Repeater ID="catlist" runat="server" onitemcreated="catlist_ItemCreated" onitemcommand="catlist_ItemCommand" onitemdatabound="catlist_ItemDataBound">
<asp:Label ID="lblCommentID" runat="server" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem, "CID") %>'></asp:Label>
  <div class="wall-container">
  <div class="wall-left">
<a href="<%# "user-wall.aspx?ID=" + Eval("UID") %>"><asp:Image ID="Image4" ImageUrl='<%# string.Format("~/avatars/{0}", Eval("Avatar")) %>' runat="server" Width="55" Height="55" BorderWidth="0px"/></a>  
  <div class="wall-right">
    <p><a href="<%# "user-wall.aspx?ID=" + Eval("UID") %>"><%# DataBinder.Eval(Container.DataItem, "Fname") %></a> 
   - <%# DataBinder.Eval(Container.DataItem, "Comment") %>
  <br />
  <small><%# DataBinder.Eval(Container.DataItem, "Added") %></small>
  <div class="comments">
    <!-- start child repeater -->
    <asp:repeater id="childRepeater" runat="server">
             <asp:Label ID="Label4" runat="server" Text="Label" Visible="false"></asp:Label>
             <div style="height:auto;margin-bottom:12px">
   <a href="<%# "user-wall.aspx?ID=" + Eval("cUID") %>"><asp:Image ID="Image5" runat="server" ImageUrl='<%# string.Format("~/avatars/{0}", Eval("cAvatar")) %>' runat="server" Width="45px" Height="45px"/></a>
      <p><a href="<%# "user-wall.aspx?ID=" + Eval("cUID") %>"><%# DataBinder.Eval(Container.DataItem, "cFname") %></a> 
   - <%# DataBinder.Eval(Container.DataItem, "cComment") %>
  <br />
  <small><%# DataBinder.Eval(Container.DataItem, "cAdded") %></small>
      <!-- end child repeater --> 
      <div style="float:left">
      <asp:TextBox ID="TextBox2" runat="server" CssClass="text-comment" onfocus="this.value='';" 
        onblur="if (this.value=='') this.value='Write a comment';" 
        value="Write a comment" ForeColor="#A79090"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Submit"  CommandArgument='<%# Eval("CID") %>'/> 
<!-- end parent repeater -->      

So as you can see i have user comments and then i enable them to reply. I am having problems with this section of the code:-

&lt;asp:TextBox ID="TextBox2" runat="server" CssClass="text-comment" onfocus="this.value='';" 
    onblur="if (this.value=='') this.value='Write a comment';" 
    value="Write a comment" ForeColor="#A79090"&gt;&lt;/asp:TextBox&gt;
&lt;asp:Button ID="Button1" runat="server" Text="Submit"  CommandArgument='&lt;%# Eval("CID") %&gt;'/&gt; 

When i click the button it does not execute.

My code behind is as follows:-

.cs file

    protected void btn_Click(object sender, EventArgs e)
        Button btn = sender as Button;
        if (btn != null)
            string CID = btn.CommandArgument.ToString();

            RepeaterItem item = btn.NamingContainer as RepeaterItem;
            if (item != null)
                TextBox tbox = item.FindControl("TextBox2") as TextBox;
                if (tbox != null)
                        string conString = "Data Source=SQLB23.webcontrolcenter.com;User ID=wbsd;Password=******";
                        SqlConnection empConnection = new SqlConnection(conString);

                        string insertStatement = "INSERT INTO hussaini_comment_responses ([comment_id], [user_id], [comment], [date_added]) "
                            + "VALUES (@comment_id, @user_id, @comment, GetDate())";

                        SqlCommand insertCommand = new SqlCommand(insertStatement, empConnection);

                        insertCommand.Parameters.Add("@comment_id", SqlDbType.Int).Value = CID;
                        insertCommand.Parameters.Add("@user_id", SqlDbType.Int).Value = System.Convert.ToInt32(Session["MEM_ID"]);
                        insertCommand.Parameters.Add("@comment", SqlDbType.Char).Value = tbox.Text;


                        Response.Redirect("user-wall.aspx?ID= " + Request.QueryString["ID"].ToString() + "");
    protected void catlist_ItemCreated(object sender, RepeaterItemEventArgs e)
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            Button btn = e.Item.FindControl("Button1") as Button;
            if (btn != null)
                btn.Click += new EventHandler(btn_Click);
    protected void catlist_ItemDataBound(object sender, RepeaterItemEventArgs e)
        Repeater childRepeater = e.Item.FindControl("childRepeater") as Repeater;
        if (childRepeater != null)
            StringBuilder sSQL2 = new StringBuilder();
            sSQL2.Append("SELECT (hussaini_comment_responses.response_id) AS cRID, ");
            sSQL2.Append("(hussaini_comment_responses.comment_id) AS cCID, ");
            sSQL2.Append("(hussaini_comment_responses.comment) AS cComment, ");
            sSQL2.Append("(hussaini_comment_responses.user_id) AS cUID, ");
            sSQL2.Append("(hussaini_comment_responses.date_added) AS cAdded, ");
            sSQL2.Append("(hussaini_users.fname) AS cFname, ");
            sSQL2.Append("(hussaini_users.avatar) AS cAvatar ");
            sSQL2.Append("FROM hussaini_comment_responses ");
            sSQL2.Append("LEFT OUTER JOIN hussaini_users ON ");
            sSQL2.Append("hussaini_comment_responses.user_id = hussaini_users.user_id ");
            sSQL2.Append("WHERE hussaini_comment_responses.comment_id = @commentID");
            DataTable dt = new DataTable();
            using (SqlConnection conDotNet = new SqlConnection("Data Source=SQLB23.webcontrolcenter.com;User ID=wbsd;Password=*******"))
                SqlCommand cmd2 = new SqlCommand(sSQL2.ToString(), conDotNet);

                Label lblCID = (Label)e.Item.FindControl("lblCommentID");
                cmd2.Parameters.AddWithValue("@commentID", lblCID.Text);

                using (SqlDataAdapter sda = new SqlDataAdapter(cmd2))
            childRepeater.DataSource = dt;
    protected void catlist_ItemCommand(object source, RepeaterCommandEventArgs e)


So why does the button not execute? How can i fix this?

Someone please help


Check your other thread.