I have an rowdatabound method that is common for two gridviews. Part of the task for this method, is to asign values to last column of the gridview.
The gridviews are the same, but the values are different from the two gridviews. So i need to check if i’m asigning vaules to the first gridview or the other one.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//Here i need to check which gridview (Gridview1 or Gridview2)
if (e.Row.RowType == DataControlRowType.DataRow)
{
{
int CellValue = Convert.ToInt32(e.Row.Cells[0].Text);
if (CellValue == 1)
e.Row.Cells[7].Text = "" + patchWeekTwo[0] + "t";
else if (CellValue == 2)
e.Row.Cells[7].Text = "" + patchWeekTwo[1] + "t";
else if (CellValue == 3)
e.Row.Cells[7].Text = "" + patchWeekTwo[2] + "t";
else if (CellValue == 4)
e.Row.Cells[7].Text = "" + patchWeekTwo[3] + "t";
else
e.Row.Cells[7].Text = "" + patchWeekTwo[4] + "t";
}
}
}
You can check if
senderisGridView1orGridView2:Note that this works only if
GridView1is declared on top of the page and not in one of it’s childsNamingContainers. Then you could check the id: