I have a DataTable that I am creating and binding to a GridView. Currently the headers do not have any spaces and it makes it hard to read. I want to space them out but I’m having a minor issue.
What I am trying to accomplish :
Dim dc As Data.DataColumn
dc = New Data.DataColumn("Updated Date", System.Type.GetType("System.String"))
dt.Columns.Add(dc)
What I currently have :
Dim dc As Data.DataColumn
dc = New Data.DataColumn("UpdatedDate", System.Type.GetType("System.String"))
dt.Columns.Add(dc)
I know that I can set the HeaderText in the columns declaration like below, but I won’t know how any columns I am going to have. And would rather the columns be generated automatically.
<Columns>
<asp:BoundField DataField="UpdatedDate" HeaderText="Updated Date" />
</Columns>
I believe names should not contain spaces, unless you want to create yourself bigger problems later. You can generate the column titles automatically by writing a line of code that inserts a space every time there is a capital letter in the name.