|
 |
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
 |
|
|
 |
|

August 18th, 2004, 03:29 AM
|
Authorized User
|
|
Join Date: Nov 2003
Location: Mataro, Barcelona, Spain.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
bindings & date format
Hi to all!
I am getting an error when I try to do the next format adjustment:
Binding b50;
b50 = new Binding("Text", dsPacientes, "PACIENTES.pac_fecha_nac");
b50.Format += new ConvertEventHandler(this.txtFechaFormat);
txtFechaNac.DataBindings.Add(b50);
...
private void txtFechaFormat(object sender, ConvertEventArgs e)
{
DateTime dt = (DateTime) e.Value;
e.Value = dt.ToString("MM/dd/yyyy hh:mm:sszzz");
}
The problem is inside the function "txtFechaFormat". I've tried out with diff formats, with no results.
Does anybody can help me?
Thanks
|

August 18th, 2004, 08:53 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
WE can best help people when they provide the error they are getting.
That said, i might be missing something- but this code doesn't even look like it's close to being correct.
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|

August 18th, 2004, 01:10 PM
|
Authorized User
|
|
Join Date: Nov 2003
Location: Mataro, Barcelona, Spain.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok. The error is:
'System.InvalidCastException' in system.windows.forms.dll
Additional information: The specified conversion is not valid.
I hope it helps.
|

August 18th, 2004, 02:22 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
and e.value takes a string?
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|

August 18th, 2004, 02:44 PM
|
Authorized User
|
|
Join Date: Nov 2003
Location: Mataro, Barcelona, Spain.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I think so.
I used it like i read in "binding in windows forms applications" from the help
-------------------------------
World only exists into your mind.
|

August 18th, 2004, 03:38 PM
|
Authorized User
|
|
Join Date: Nov 2003
Location: Mataro, Barcelona, Spain.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Hal,
I've finally solved, in the way:
private void txtFechaFormat(object sender, ConvertEventArgs e)
{
DateTime dt = (DateTime) e.Value;
string s = dt.ToString("dd/MM/yyyy");
e.Value = s;
}
I really don't understand at all, because I am doing the same... or that's what I think... never mind, it works fine.
:)
-------------------------------
World only exists into your mind.
|

August 22nd, 2004, 10:47 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
excuse me what about giving format in a grid?! how can I format a cell in a grid?!
Always:),
Hovik Melkomian.
|

August 25th, 2004, 02:49 AM
|
Authorized User
|
|
Join Date: Nov 2003
Location: Mataro, Barcelona, Spain.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry, I don't use datagrids. I don't know.
-------------------------------
World only exists into your mind.
|

August 25th, 2004, 06:10 AM
|
Friend of Wrox
|
|
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
|
|
yes,Hovik we can do it easily...
Code:
<asp:BoundColumn DataFormatString="{0:d}" DataField="yourColumn"></asp:BoundColumn>
--------------------------------------------
Mehdi.:)
|

August 25th, 2004, 03:33 PM
|
Registered User
|
|
Join Date: Aug 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello,
Also in response to Hovik, the date format in your datagrid is based on the date format of the users regional settings. I couldn't figure out a way to change the date format in my datagrid for my non ASP application without changing it in the Regional Settings. If somebody knows of a way and would like to share, please feel free...
Devon
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |