我有一个 rowdatabound 方法,这对于两个 gridviews 很常见。此方法的部分任务是将值分配给 gridview 的最后一列。
网格视图相同,但值与两个网格视图不同。所以我需要检查我是否将 vaules 分配给第一个 gridview 或另一个。
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";
}
}
}