title: Get Gridview RowIndex outside of the gridview
body: <p>My Button1 is inside a Panel, I want to access the rowindex so that I will hide that Imagebutton. But when I enter debug mode, the GridView1.SelectedIndex has a null value. pleaase help!</p>
  
  <pre><code>  protected void Button1_Click1(object sender, EventArgs e)
      {
  
          foreach (GridViewRow row in GridView1.Rows)
          {
              if (row.RowType == DataControlRowType.DataRow)
              {
                  if (row.RowIndex == Convert.ToInt32(GridView1.SelectedIndex))
                  {
                      ImageButton StopButton = (ImageButton)row.FindControl("stopImageButton");
                      ImageButton StartButton = (ImageButton)row.FindControl("startImageButton");
                      StopButton.Visible = true;
                      StartButton.Visible = false;          
                  }
              }
          }
  
          this.StopTimeNotesPanel_ModalPopupExtender.Hide();
      }
  </code></pre>