Tuesday, January 31, 2012

How to find the Gridview Row index(On click link button) 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;


        }