I'm guessing, since you haven't posted the exception details, that you're getting a
NullReferenceException
when you call
GridView1.SelectedRow.FindControl(...)
; your grid doesn't have a selected row, so you're trying to call a method on a
null
reference.
Try using the
sender
parameter to get the parent row, and find your controls from there:
protected void ddlEmp_SelectedIndexChanged(object sender, EventArgs e)
{
Control row = ((Control)sender).NamingContainer;
DropDownList ddlEmp = (DropDownList)row.FindControl("ddlEmp");
DropDownList ddlEmp2 = (DropDownList)row.FindControl("ddlEmp2");
Label lblPointName = (Label)ddlEmp.NamingContainer.FindControl("lblPointName");
Label lblPointName1 = (Label)ddlEmp.NamingContainer.FindControl("lblPointName1");
string Emp1 = ddlEmp.SelectedValue;
string Emp2 = ddlEmp2.SelectedValue;
string pointname = lblPointName.Text;
string pointname1 = lblPointName1.Text;
...
}
If that doesn't solve the problem, then you'll need to post the full details of the exception you're getting.