HighTechTalks DotNet Forums  

I got an error

ASP.net ASP.net discussions (microsoft.public.dotnet.framework.aspnet)


Discuss I got an error in the ASP.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
redbull
 
Posts: n/a

Default I got an error - 07-02-2010 , 05:42 AM






Hi guys, I've created a simple webpage with a datagridview, my business
object.
If i try to modify a record i get an error on date value:

Dettagli eccezione: System.InvalidOperationException: Impossible to convert
the value of parameter 'DataNascita' from 'System.String' to
'System.DateTime'.
What should I do?
Thanks

Reply With Quote
  #2  
Old   
Mr. Arnold
 
Posts: n/a

Default Re: I got an error - 07-02-2010 , 06:24 AM






redbull wrote:
Quote:
Hi guys, I've created a simple webpage with a datagridview, my business
object.
If i try to modify a record i get an error on date value:

Dettagli eccezione: System.InvalidOperationException: Impossible to
convert the value of parameter 'DataNascita' from 'System.String' to
'System.DateTime'.
What should I do?
Thanks
You can't populate a DateTime value field or variable with string data
representing a date and time.

The string date and time must be converted over to System.Datetime
before the field or variable can be populated by string data the
represents a date and time.

You should look up how to use the 'Convert' statement.

Reply With Quote
  #3  
Old   
redbull
 
Posts: n/a

Default Re: I got an error - 07-02-2010 , 06:48 AM



"Mr. Arnold" <Arnold (AT) Arnold (DOT) com> ha scritto nel messaggio
news:Ox8s0kdGLHA.5700 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
Quote:
redbull wrote:
Hi guys, I've created a simple webpage with a datagridview, my business
object.
If i try to modify a record i get an error on date value:

Dettagli eccezione: System.InvalidOperationException: Impossible to
convert the value of parameter 'DataNascita' from 'System.String' to
'System.DateTime'.
What should I do?
Thanks

You can't populate a DateTime value field or variable with string data
representing a date and time.

The string date and time must be converted over to System.Datetime before
the field or variable can be populated by string data the represents a
date and time.

You should look up how to use the 'Convert' statement.

to insert the value i do:
persona.data= Convert.ToDateTime(Me.TextBox3.Text)

The problem raises when i click on update dategridview.....but how can I
modify code related to selcet/update/insert in datagridview?
Thanks

Reply With Quote
  #4  
Old   
Mr. Arnold
 
Posts: n/a

Default Re: I got an error - 07-02-2010 , 01:54 PM



redbull wrote:
Quote:
"Mr. Arnold" <Arnold (AT) Arnold (DOT) com> ha scritto nel messaggio
news:Ox8s0kdGLHA.5700 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
redbull wrote:
Hi guys, I've created a simple webpage with a datagridview, my
business object.
If i try to modify a record i get an error on date value:

Dettagli eccezione: System.InvalidOperationException: Impossible to
convert the value of parameter 'DataNascita' from 'System.String' to
'System.DateTime'.
What should I do?
Thanks

You can't populate a DateTime value field or variable with string data
representing a date and time.

The string date and time must be converted over to System.Datetime
before the field or variable can be populated by string data the
represents a date and time.

You should look up how to use the 'Convert' statement.


to insert the value i do:
persona.data= Convert.ToDateTime(Me.TextBox3.Text)

The problem raises when i click on update dategridview.....but how can I
modify code related to selcet/update/insert in datagridview?
Thanks


What is 'DataNascita', because that's what it doesn't like?

Reply With Quote
  #5  
Old   
redbull
 
Posts: n/a

Default Re: I got an error - 07-03-2010 , 03:15 AM



"Mr. Arnold" <Arnold (AT) Arnold (DOT) com> ha scritto nel messaggio
news:#8mdTghGLHA.5668 (AT) TK2MSFTNGP04 (DOT) phx.gbl...

Quote:
What is 'DataNascita', because that's what it doesn't like?
db sqlserver 2008, datanascita means "birth date" and it is a date type on
the db
on the business object I have defined the property DataNascita like a
datetime

The problem is got when i call update function on datagridview....

Reply With Quote
  #6  
Old   
Mr. Arnold
 
Posts: n/a

Default Re: I got an error - 07-04-2010 , 10:17 PM



redbull wrote:
Quote:


"Mr. Arnold" <Arnold (AT) Arnold (DOT) com> ha scritto nel messaggio
news:#8mdTghGLHA.5668 (AT) TK2MSFTNGP04 (DOT) phx.gbl...

What is 'DataNascita', because that's what it doesn't like?

db sqlserver 2008, datanascita means "birth date" and it is a date type
on the db
on the business object I have defined the property DataNascita like a
datetime

The problem is got when i call update function on datagridview....


Well, you're going to need to come up with something else, because
apparently that variable type cannot be cast to a string by the
gridview, unless you step in with a function that does so.

Reply With Quote
  #7  
Old   
redbull
 
Posts: n/a

Default Re: I got an error - 07-05-2010 , 12:41 AM



"Mr. Arnold" <Arnold (AT) Arnold (DOT) com> ha scritto nel messaggio
news:eXymfC$GLHA.552 (AT) TK2MSFTNGP06 (DOT) phx.gbl...

Quote:
Well, you're going to need to come up with something else, because
apparently that variable type cannot be cast to a string by the gridview,
unless you step in with a function that does so.
How can I do it? Give m some help please.
I don't know what I must do

Reply With Quote
  #8  
Old   
Mr. Arnold
 
Posts: n/a

Default Re: I got an error - 07-05-2010 , 06:10 AM



redbull wrote:
Quote:

"Mr. Arnold" <Arnold (AT) Arnold (DOT) com> ha scritto nel messaggio
news:eXymfC$GLHA.552 (AT) TK2MSFTNGP06 (DOT) phx.gbl...

Well, you're going to need to come up with something else, because
apparently that variable type cannot be cast to a string by the
gridview, unless you step in with a function that does so.

How can I do it? Give m some help please.
I don't know what I must do
The control has events like update/select/delete etc, etc on the
client-side and the server-side. On the client-side, you can call a
Javascript function that can look at the field and do the conversion to
the type you need. On the server-side, you can goto the event for the
control's method on the codebehind file and do something there.

You should use Bing or Google to look up the events on both sides for
the control and find examples on how you can use the events with code.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.