By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,353 Members | 1,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,353 IT Pros & Developers. It's quick & easy.

DataGrid Column Format

P: n/a
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.
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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]
- mv*@spam.guard.caspershouse.com

"Daniel M." <dm*****@hotmail.com> wrote in message
news:us**************@tk2msftngp13.phx.gbl...
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.

Nov 16 '05 #2

P: n/a
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Ob**************@TK2MSFTNGP11.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Daniel M." <dm*****@hotmail.com> wrote in message
news:us**************@tk2msftngp13.phx.gbl...
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.


Nov 16 '05 #3

P: n/a
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]
- mv*@spam.guard.caspershouse.com

"Daniel M." <dm*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:Ob**************@TK2MSFTNGP11.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Daniel M." <dm*****@hotmail.com> wrote in message
news:us**************@tk2msftngp13.phx.gbl...
>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.
>
>



Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.