Actually it does not work on PreRender event, so you have to do it in the RowCreated event:
protected void GridViewLot_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
if (!string.IsNullOrEmpty(lt.CustomAttributeName1)) e.Row.Cells[5].Text = lt.CustomAttributeName1; else e.Row.GridView.Columns[5].Visible = false;
}
}
