473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DataGrid Column Format

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
3 9938
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: J.B | last post by:
I have a datagrid that will display different datasets, (it runs different sprocs based on a value in the querystring) but it will always return 6 columns. The 5th and 6th columns are always Date...
4
by: yer darn tootin | last post by:
Does anyone know the sort expression for a column that's data has been returned in the format, eg '07 Jul 05'?? The sort expression {..:"dd mmm yy"} doesn't work ( if the column was returned as...
5
by: cwbp17 | last post by:
Hi all, Have a datagrid that displays the price column of a table. Went to the Datagrid's Property builder and set the 'Data Formatting expression' for the PRICE column to {0:c}, so that the...
14
by: Brett Sinclair | last post by:
Hello everybody I'm still on the learning curve here...and from what I read, I created inherited datagrid class so I could have icons, combobox...etc in the columns of my datagrid. The grid...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
8
by: Scott Meddows | last post by:
I have a datagrid control that I've inherited from the base datagrid control (Source below). I am applying a datatable style onto the datatable that I assign as my datasource. All of my column...
6
by: Agnes | last post by:
I understand it is impossible, but still curious to know "Can I freeze several column in the datagrid, the user can only scroll the first 3 columns (not verical), for the rest of the coulumn, it is...
13
by: pmcguire | last post by:
I have a DataGrid control for which I have also created several new extended DataGridColumnStyles. They behave pretty nicely, but I can't figure out how to implement Selected Item formatting for...
2
by: Javier | last post by:
Hi Everyone, I have a dynamic checkbox in a datagrid that uses the ITemplate interface and has the checkchanged event wired up. When the checkbox is checked, the event event handler that...
3
by: Horselover Fat | last post by:
Hi, I have a column in a database that holds elapsed time in milliseconds and I want to display that column in a DataGrid in a specific format (d.hh:mm:ss.fff). However, the closest I can get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.