This code will throw an exception:
GridDataItem dItem = e.Item as GridDataItem; |
// rename edit button |
TableCell cell = dItem["cmdEdit"]; |
if (cell != null) |
{ |
Control control = cell.Controls[0]; |
if (control != null) |
{ |
LinkButton cmdEdit = control as LinkButton; |
cmdEdit.Text = "View"; |
} |
} |
Instead of handling exceptions, I would rather prefer to check if the column exists prior to accessing it. I couldn't find any simple way of checking column existense by unique name.
Why don't you introduce a method GridDataItem.ContainsColumn(uniqueName) ?