hi,
I have had to create a bunch of field names in my table as (i.e) "20071225" (for 25-dec-2007).
But in my datagrid I want "25-dec-2007" as my column headers.
How would i achieve this?
Thanks,
John
I've answered my own question in case anyone else was interested.
I wanted to change my "col" (foreach(DataColumn colin dt.Columns) )
- where col.ColumnName.ToString() = "20071225"
I ended up changing the DataTable column names and then the bind to the Datagrid simply picked them up correctly.
-------
string stopval = col.ColumnName.ToString();
string year = stopval.Substring(0, 4);
string month = stopval.Substring(4, 2);
string day = stopval.Substring(6, 2);
// extra faffing to get MON
dtme = Convert.ToDateTime(day + "-" + month + "-" + year);
string strMonth = dtme.ToString("MMM");
col.ColumnName = day + "-" + strMonth + "-" + year;
--------
- now col.ColumnName.ToString() = "25-Dec-2007"
No comments:
Post a Comment