グリッドビューのすべての空のセルをオレンジ色で表示する方法があるのだろうかと思っていました。私のGridViewの列は動的に生成されます。どんな助けもありがとうございます。色GridViewのすべての空のセル
ありがとうございます!
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//check if the rowtype is a datarow
if (e.Row.RowType == DataControlRowType.DataRow)
{
//loop all the cells in the row
for (int i = 0; i < e.Row.Cells.Count; i++)
{
int value = 0;
//try converting the cell value to an int
try
{
value = Convert.ToInt32(e.Row.Cells[i].Text);
}
catch
{
}
//check the value and set the background color
if (value == "")
{
e.Row.Cells[i].BackColor = Color.Green;
}
else
{
e.Row.Cells[i].BackColor = Color.White;
}
}
}
}
OnRowDataBoundイベントが出発点です。ここでは、すべてのセルをループしてその値を確認できます。 –
[こちら](http://stackoverflow.com/questions/31528633/how-to-change-gridview-cell-color-based-on-condition-using-c-sharp/31529889#31529889)をご覧ください。 – jsanalytics
あなたはどうしたらいいか私に正確に教えてもらえますか? –