I have a GridView with 10 columns. On a certain condition, I want to add a new column called "Expiration Date". The problem is that when the user presses "Search" again (Postback) the column is added again.
I check before adding the column, to see if it already exists:
BoundField dtExp = new BoundField
{DataField = "DateTimeExpired", HeaderText = "Expiration Date", DataFormatString = "{0:d}"};
if (!grid.Columns.Contains(dtExp)){grid.Columns.Add(dtExp);}
But the problem is that even if the column already exists, "Contains" returns false.
What am I doing wrong?
Thanks!