Hello everyone,
I'm going to share the code-sample of row index in gridview in c# .net using on click of link-button and image button.
Table of Contents
1. On click link button find gridview row index in C#.
2. On click Image button find gridview row index in C#.
Note: Image is a Temple field item, we create a click and then generate the events of on row and get the index. Using the line of code
and then get the Cell values with using index. i.e.
For more details you can seen the below example.
1. Row index in gridview (On click link button)
The above code is use to find the row index of the grid view, when you click to Insert Update Edit and Delete on the gridview row image button/ link button etc.
I'm going to share the code-sample of row index in gridview in c# .net using on click of link-button and image button.
Table of Contents
1. On click link button find gridview row index in C#.
2. On click Image button find gridview row index in C#.
Note: Image is a Temple field item, we create a click and then generate the events of on row and get the index. Using the line of code
[ int index = (((LinkButton)sender).Parent.Parent
as GridViewRow).RowIndex; ]
and then get the Cell values with using index. i.e.
[ string strFilePath =
GridViewId.Rows[index].Cells[1].Text; ]
For more details you can seen the below example.
1. Row index in gridview (On click link button)
protected void
lkbVideo_Click(object sender, EventArgs e)
{
int index = (((LinkButton)sender).Parent.Parent
as GridViewRow).RowIndex;
string strFilePath =
GridViewId.Rows[index].Cells[1].Text;
}
2. Row index in gridview (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;
}