Find control in gridview_rowcommand event
protected void dgAvailability_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName == "Save")
{
GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);
DropDownList ddl = (DropDownList)row.Cells[3].FindControl("ddlResponse");
BFixturePlayer obj = new BFixturePlayer();
obj.Key = int.Parse(dgAvailability.DataKeys[row.RowIndex].Value.ToString());
obj.Response = int.Parse(ddl.SelectedValue);
obj.SaveResponse();
LoadAvailability();
}
}
catch (Exception exp)
{
divError.InnerHtml = exp.Message;
}
}
{
try
{
if (e.CommandName == "Save")
{
GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);
DropDownList ddl = (DropDownList)row.Cells[3].FindControl("ddlResponse");
BFixturePlayer obj = new BFixturePlayer();
obj.Key = int.Parse(dgAvailability.DataKeys[row.RowIndex].Value.ToString());
obj.Response = int.Parse(ddl.SelectedValue);
obj.SaveResponse();
LoadAvailability();
}
}
catch (Exception exp)
{
divError.InnerHtml = exp.Message;
}
}
Comments