DataGrid Column Format

  • Thread starter Thread starter Daniel M.
  • Start date Start date
D

Daniel M.

I have a query that gets a string column containing a date, ex. 20040825.
If I use the property builder to format the string to 08/25/2004 it does not
work because it only accepts datetime columns. How can I convert or format
the string. Could I add a new dataset/datatable column containing the value
as I need it.

Thanks.
 
Daniel,

Yes, you could add a new column that has the value in a DateTime format.
The thing is, you would have to be responsible for populating this column,
and keeping it up to date as your data chances.

Hope this helps.
 
Nicholas, I am not populating any column, I have the grid bound to a
dataset. Now, it is just for reporting purposes.

Can you send me an example of how to add a new column formatted as a date
from a string column stored in the datatable.

Thanks

Nicholas Paldino said:
Daniel,

Yes, you could add a new column that has the value in a DateTime format.
The thing is, you would have to be responsible for populating this column,
and keeping it up to date as your data chances.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Daniel M. said:
I have a query that gets a string column containing a date, ex. 20040825.
If I use the property builder to format the string to 08/25/2004 it does
not
work because it only accepts datetime columns. How can I convert or
format
the string. Could I add a new dataset/datatable column containing the
value
as I need it.

Thanks.
 
Daniel,

It's as easy as calling Add on the object exposed by the Columns
property on a DataTable. Once you do that, you will have to cycle through
all the rows, converting the string value to a DateTime. You ^might^ be
able to have the column to the parsing yourself, but I am not sure that this
is possible, as I don't know if you can set the format in the Expression
property.

I would check the Expression property to determine if there is a
conversion that lets you specify the format.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Daniel M. said:
Nicholas, I am not populating any column, I have the grid bound to a
dataset. Now, it is just for reporting purposes.

Can you send me an example of how to add a new column formatted as a date
from a string column stored in the datatable.

Thanks

in
message news:[email protected]...
Daniel,

Yes, you could add a new column that has the value in a DateTime format.
The thing is, you would have to be responsible for populating this
column,
and keeping it up to date as your data chances.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Daniel M. said:
I have a query that gets a string column containing a date, ex.
20040825.
If I use the property builder to format the string to 08/25/2004 it
does
not
work because it only accepts datetime columns. How can I convert or
format
the string. Could I add a new dataset/datatable column containing the
value
as I need it.

Thanks.
 
Back
Top