My DataTable is programatically generated, and contains objects of type JobInstance in the cells.
DataTable dataTable = new DataTable();
// first column - label
dataTable.Columns.Add("JobType", typeof(string));
// other columns (data-driven)
foreach(string config in Configurations)
{
DataColumn col = new DataColumn(config, typeof(JobInstance)); // !!!
dataTable.Columns.Add(col);
}
// rows
foreach(string jobType in JobTypes)
{
DataRow row = dataTable.NewRow();
row["JobType"] = jobType;
foreach(string config in Configurations)
{
row[config] = GetJobInstance(jobType, config); // returns a JobInstance object
}
dataTable.Rows.Add(row);
}
When I bind this DataTable to an ASP GridView, it only displays the first column. But if I remove the "typeof(Job)" when creating the column (the line with // !!!), the GridView displays all the columns by showing the result of JobInstance.ToString() in the cells. However, I have no access to the underlying JobInstance object, only the string values that are being displayed.
I need access to the JobInstance object when displaying the GridView (for example in the OnRowDataBound), because I want to access the fields inside JobInstance for each cell to determine formatting options, and add other links in each cell.
Is this possible?
Thanks.