-1
if (e.Row.RowType == DataControlRowType.DataRow)
    {
        int esal = int.Parse(e.Row.Cells[3].Text.ToString());
        if (esal > 12000)
        {
            e.Row.ForeColor = System.Drawing.Color.Blue;
            e.Row.BackColor = System.Drawing.Color.LightPink;
            e.Row.Font.Italic = true;
        }
        else if (esal == 15000)
        {
            e.Row.ForeColor = System.Drawing.Color.Brown;
            e.Row.BackColor = System.Drawing.Color.LightBlue;
            e.Row.Font.Italic = true;
        }
        else
        {
            e.Row.ForeColor = System.Drawing.Color.White;
            e.Row.BackColor = System.Drawing.Color.LightGreen;
            e.Row.Font.Italic = true;
        }

    }

これを試してみましたが、入力文字列が正しい形式ではないなどの例外が発生しました..助けてください...

4

2 に答える 2

1
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (!string.IsNullOrEmpty(e.Row.Cells[3].Text))
{

    int esal = int.Parse(e.Row.Cells[3].Text.ToString());
    if (esal > 12000)
    {
        e.Row.ForeColor = System.Drawing.Color.Blue;
        e.Row.BackColor = System.Drawing.Color.LightPink;
        e.Row.Font.Italic = true;
    }
    else if (esal == 15000)
    {
        e.Row.ForeColor = System.Drawing.Color.Brown;
        e.Row.BackColor = System.Drawing.Color.LightBlue;
        e.Row.Font.Italic = true;
    }
    else
    {
        e.Row.ForeColor = System.Drawing.Color.White;
        e.Row.BackColor = System.Drawing.Color.LightGreen;
        e.Row.Font.Italic = true;
    }
}
}
于 2013-09-25T13:10:17.133 に答える