title: Linkbutton inside a gridview not firing
body: <pre><code>&lt;asp:GridView ID="gvBlockUnblock" runat="server" AutoGenerateColumns="False" 
                         BackColor ="AliceBlue"
                        onrowdatabound="gvBlockUnblock_RowDataBound" DataKeyNames="CPID,PUBLISHED"
                      style="margin-top: 0px" 
                      AllowPaging="True" onpageindexchanging="gvBlockUnblock_PageIndexChanging" 
                      PageSize="10" EnableViewState= "true"
                      onselectedindexchanged="gvBlockUnblock_SelectedIndexChanged" &gt;
  
          &lt;Columns&gt;
  
                      &lt;asp:TemplateField HeaderText="S.No."&gt;
                      &lt;ItemTemplate&gt;
                      &lt;asp:LinkButton ID="lbSNo" runat="server" 
                      Text='&lt;%# (Eval("sno")) %&gt;'
                      PostBackUrl='&lt;%#"~/_UILayer/ComplaintReport.aspx?PINo="+Eval("CPID") %&gt;' &gt;
                      &lt;/asp:LinkButton&gt;
                      &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
  
           &lt;asp:BoundField  HeaderText = "Complaint" /&gt;
  
           &lt;asp:HyperLinkField   DataNavigateUrlFields="CPID" datatextfield = "CPID"
                  DataNavigateUrlFormatString="WebForm1.aspx?CPID={0}" HeaderText=" Problem Item No"/&gt;
  
  
              &lt;asp:BoundField  DataField="NewComplaints" 
                  HeaderText="Number of New Complaints" SortExpression="NewComplaints" /&gt;
              &lt;asp:BoundField DataField="TotalNumberofComplaints" 
                  HeaderText="Total Number of Complaints" SortExpression="TotalNumberofComplaints" /&gt;
              &lt;asp:BoundField DataField="NumberofUnblocks" HeaderText="Number of Unblocks" 
                  SortExpression="TotalNumberofComplaints" /&gt;
  
  
  
            &lt;asp:TemplateField  HeaderText = "Comments"&gt;
             &lt;ItemTemplate&gt;
                          &lt;asp:TextBox ID="txtAdminComment" Font-Names="Arial" ReadOnly="false" Width="200" Height="30"
                              TextMode="multiLine" runat="server" BorderStyle="NotSet"&gt;&lt;/asp:TextBox&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
  
  
             &lt;asp:TemplateField  HeaderText = " Block / Unblock"&gt;
                  &lt;ItemTemplate&gt;
                       &lt;asp:button ID ="btnBlockUnblock"  runat = "server" 
                           Text = '&lt;%# CheckBlock(Eval("PUBLISHED")) %&gt;' CommandName="Select" 
                          CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;"  CausesValidation="False"  /&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
  
  
  
                      &lt;asp:HyperLinkField   DataNavigateUrlFields="CPID"  Text="View Details"  
                  DataNavigateUrlFormatString="ItemHistoryForm.aspx?CPID={0}" HeaderText=" Problem Item No"/&gt;
  
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>aspx.cs </p>
  
  <pre><code>   protected void gvBlockUnblock_SelectedIndexChanged(object sender, EventArgs e)
      {
          string ComplaintProfileId = gvBlockUnblock.DataKeys[gvBlockUnblock.SelectedIndex].Values["CPID"].ToString();
          string ISPUBLISHED = gvBlockUnblock.DataKeys[gvBlockUnblock.SelectedIndex].Values["PUBLISHED"].ToString();
  
          string date = System.DateTime.Now.ToString();
          TextBox tb = (TextBox)gvBlockUnblock.Rows[gvBlockUnblock.SelectedIndex].FindControl("txtAdminComment");
          string Comment = tb.Text;
          if (string.IsNullOrEmpty(Comment))
          {
  
              WebMsgBox.Show("empty");
          }
          else
          {
              if (ISPUBLISHED == "N")
              {
                  ISPUBLISHED = "N";
              }
              else
              {
                  ISPUBLISHED = "Y";
              }
              string AdminComment = (System.DateTime.Now.ToString() + " :  " + Comment);
  
              AddCommentBLL.InsertComment(AdminComment, ComplaintProfileId, ISPUBLISHED);
              gvBlockUnblock.DataSource = AddCommentBLL.GetItem();
              gvBlockUnblock.DataBind();
          }
      }
  </code></pre>
  
  <p>So, on click of the button ID ="btnBlockUnblock", this grid view selectedindex changed needs to fire. The page is refreshing though.</p>
  
  <p>Thanks
  Sun</p>