First of all, I’ve got a DataTable which stores data in a number of fields. One of these fields stores a value, which can either be ‘1’, ‘0’ or ‘-1’.
What I’m trying to accomplish is to fill a GridView with all the data contained in this DataTable, except for the previously mentioned field. Instead of this field, I would like to display a column which shows a different icon depending on the value (either 0, 1 or -1).
In other words, if a row contains a value of ‘0’ in this field within the DataTable, I would like a red circle icon to appear in the equivalent cell within the GridView.
Could anyone kindly explain how this may be accomplished? Below is some code which may help to explain the situation further.
The GridView is filled with the data contained in the DataTable.
source = new DataSource();
TableGridView.DataSource = source.FillTable();
TableGridView.DataBind();
What should be done after this?
EDIT: Solution added as a comment below
Solved: I created the TemplateField in ASP.NET code, and the other fields programmatically in the .cs class. Next, I added a chunk of code which switches round the order of the columns. Hope someone finds this helpful.