I do it like this:
if (e.Row.Cells[3].Text != null && e.Row.Cells[3].Text != " "
&& e.Row.Cells[3].Text != "")
{
e.Row.Cells[3].Attributes.Add("readonly", "true");
}
But it doesn't work. I need to set readonly property in true when cell is empty or contains " ".