I have a GridView whose data source is built dynamically as a DataTable - how can I specify column-specific header wrapping considering I'm specifying the structure in code?
I've not found anything to deal with this specific situation as I need to wrap only some columns in specific places, e.g. wrapping the second column below after 'Long' but leaving others alone. Adding \n
or <br />
don't work as they're just treated as literals.
var statsTable = new DataTable();
statsTable.Columns.Add("Run Date", typeof(DateTime));
statsTable.Columns.Add("Needlessly Long Test Header", typeof(string));
...etc
statsTable.Rows.Add(runDate, "example", ...)
gridView.DataSource = statsTable;
gridView.DataBind();
Not sure if this is relevant, but I've found that I need to keep AutoGenerateColumns = true
on my GridView otherwise nothing shows up. This is confusing me as I thought specifying the columns would do the trick - if this is unrelated to this question I'll ask another later.
Using .Net 3.5, if that affects answers. It seems like it'd be a simple/common problem.
`? – Alex Oct 25 '11 at 16:54