Find the Gridview Row index at Runtime

Gridview Row index(On click link button):

       protected void lkbVideo_Click(object sender, EventArgs e)
        {
            int index = (((LinkButton)sender).Parent.Parent as GridViewRow).RowIndex;
            string strFilePath = GridView1.Rows[index].Cells[2].Text;


        }


Gridview Row index(On click Image button):

      protected void ImgbuttonVideo_Click(object sender, EventArgs e)
        {
            int index = (((ImageButton)sender).Parent.Parent as GridViewRow).RowIndex;
            string strFilePath = GridView1.Rows[index].Cells[2].Text;


        }

Comments

Technology