here in the 7th line i am unable to get selected index cell value pls help me to resolve.
protected void lnkbtnVerify_Click(object sender, EventArgs e)
{
try
{
LinkButton btn = (LinkButton)sender;
GridViewRow Grow = (GridViewRow)btn.NamingContainer;
Label lblBeneName = (Label)Grow.FindControl("RowNo");
}
catch(Exception e)
{
throw e;
}
}
Rajkiran SwainPosted May 4, 2023, 11:47 AM
Naimish MakwanaPosted May 4, 2023, 11:40 AM
Based on the code you have provided, it seems that you are trying to retrieve the value of a label control named "RowNo" in the selected GridView row when the user clicks on a LinkButton with the ID "lnkbtnVerify". However, you are encountering a null reference exception when trying to retrieve the GridView row index.
To fix this issue, you need to ensure that the LinkButton control is inside a GridView control and that the GridView has been populated with data. You can also check if the GridViewRow object returned by the NamingContainer property is not null before trying to access the controls inside it.
Here's an updated version of your code that includes these checks: