title: Enable Disable button on the basis of grid row
body: <p>Hi I have a grid control where i am binding list of stickers. On the above of grid , that is out side grid i have two buttons Create Sticker and Void Sticker.
  Sticker basically have three properties Active , Void and Expired displayed as text in column. There is condition of adding only one sticker at a time. Also if there is an active sticker then user cannot add another sticker until and unless its is expired or void. </p>
  
  <p>So what i want is that whenever my grid is loaded if there is an column with text active the the create / add sticker will get disabled and void will get enabled. I am using the folloing code</p>
  
  <pre><code>  /// &lt;summary&gt;
  /// Handles the RowDataBound event of the gvSticker control.
  /// &lt;/summary&gt;
  /// &lt;param name="sender"&gt;The source of the event.&lt;/param&gt;
  /// &lt;param name="e"&gt;The &lt;see cref="System.Web.UI.WebControls.GridViewRowEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
  /// &lt;remarks&gt;&lt;/remarks&gt;
  protected void gvSticker_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
  {
      if (Session["FisherId"] != null)
      {
          if (e.Row.RowType == DataControlRowType.DataRow)
          {
              Label lblStatus = (Label)e.Row.FindControl("lblStickerStatus");
  
              if (lblStatus.Text.Contains("Active"))
          {
              btnAddSticker.Enabled = false;
              btnVoidSticker.Enabled = true;
  
                  HyperLink hlStickerNum = (HyperLink)e.Row.FindControl("hlStickerNumber");
                  hlStickerNum.Attributes.Add("style", 
                          "cursor:hand;text-decoration:underline;font-weight:bold;");
              if (!string.IsNullOrEmpty(hlStickerNum.Text.Trim()))
              {
              string urlWithParameters = "Stickers.aspx?StickerId=" 
                                       + hlStickerNum.Text;
                      hlStickerNum.Attributes.Add("OnClick", "popWinNote('" +
                                      urlWithParameters + "')");
                  }
  
              }
              else
              {
                  btnAddSticker.Enabled = true;
                  btnVoidSticker.Enabled = false;
              }
  
          }
      }
      else
      {
          btnAddSticker.Enabled = true;
          btnVoidSticker.Enabled = false;
      }
  }
  </code></pre>
  
  <p>It works well on the first load of the grid. But fails whenever I changes the page index  of grid. </p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is binding and pageindexchanging events</p>
  
  <pre><code>  /// &lt;summary&gt;
      /// Handles the PageIndexChanging event of the gvSticker control.
      /// &lt;/summary&gt;
      /// &lt;param name="sender"&gt;The source of the event.&lt;/param&gt;
      /// &lt;param name="e"&gt;The &lt;see cref="System.Web.UI.WebControls.GridViewPageEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
      /// &lt;remarks&gt;&lt;/remarks&gt;
      protected void gvSticker_PageIndexChanging(object sender, GridViewPageEventArgs e)
      {
          gvSticker.PageIndex = e.NewPageIndex;
          BindStickerGrid();
      }
  
  
  
  /// &lt;summary&gt;
          /// Binds the sticker grid.
          /// &lt;/summary&gt;
          /// &lt;param name="stickers"&gt;collection of  stickers.&lt;/param&gt;
          /// &lt;remarks&gt;&lt;/remarks&gt;
          protected void BindStickerGrid()
          {
              if (Session["FisherId"] != null)
              {
                  Collection&lt;Sticker&gt; _stickerCollection = _manager.GetStickerDetailsForGrid(Session["FisherId"].ToString(), "fisher");
  
                  if (_stickerCollection != null)
                  {
                      if (_stickerCollection.Count &gt; 0)
                      {
                          gvSticker.DataSource = _stickerCollection;
                          gvSticker.DataBind();
                      }
                  }
              }
          }
  </code></pre>