What is the best way for me to access extended properties of a DataColumn on rowDataBound and apply a certain class and tool-tip if the error key exists?
protected void gridView_rowDataBound(object sender, GridViewRowEventArgs e)
{
switch (e.Row.RowType)
{
case DataControlRowType.Header:
((DataRow)e.Row.DataItem)...
break;
case DataControlRowType.DataRow:
break;
}
}
This is what I got before I got stuck. I noticed that my DataRow cast did not have a reference to the DataColumn.
The following is what I came up with, but sadly, it is tightly coupled to only one DataTable. Is there a way to do this for use in multiple DataTables? I really don't want to accept my own crappy answer.
protected void gridView_rowDataBound(object sender, GridViewRowEventArgs e)
{
switch (e.Row.RowType)
{
case DataControlRowType.Header:
foreach (DataColumn col in myDataTable.Columns)
{
if (col.ExtendedProperties["error"] != null)
{
e.Row.Cells[col.Ordinal].CssClass = "error-cell";
e.Row.Cells[col.Ordinal].ToolTip = col.ExtendedProperties["error"].ToString();
}
}
break;
case DataControlRowType.DataRow:
break;
}
}