我有一個rowdatabound方法是兩個gridviews常見的。這個方法的一部分任務是爲gridview的最後一列賦值。gridview id在rowdatabound
gridview是相同的,但是這些值不同於兩個gridviews。所以我需要檢查一下是否將第一個gridview設置爲第一個gridview或第二個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";
}
}
}