Hi, I am doing a conditional formatting on my gridview.
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string tileInput = Convert.ToString(e.Row.Cells[1].Text);
string tileDB = Convert.ToString(e.Row.Cells[0].Text);
if (tileInput == tileDB)
{
e.Row.BackColor = Color.White;
}
else
{
e.Row.BackColor = Color.Red;
}
}
}
As a result, all the incorrect input will become red-highlighted.
Now, I would like to delete all incorrect input in text box but I have no idea how to do it.
if i add in these 2,
string error = tileInput;
TextBoxTileID.Text = tileInput.Replace(error, "");
whole input in text box is replaced by empty space.
So is it possible to assign "e.Row.BackColor = Color.Red" to a variable or boolean so that I can detect that this cell is red-colored, so that I can replace the incorrect input with space in text box?
Your help is much appreciated. Thank you!