numeric field bound to a textbox control, wrong format

F

Fanor

I have a textbox control bound to a integer field of a table.
Why when the value of the field is 0, the textbox. text show as "0.0000"
????
When I tried to cast this to a integer variable there is an error:

int j ;

j= int.Parse(textbox.text) //Error

which is correct because "0.0000" is not a numeric value.

The same happens with a executescalar method whe the result is 0

.......
string mc= mycmd.executescalar().tostring();
.......

after this mc is "0.0000" !!

TIA
 
S

Santosh

Fanor said:
I have a textbox control bound to a integer field of a table.
Why when the value of the field is 0, the textbox. text show as "0.0000"
????
When I tried to cast this to a integer variable there is an error:

int j ;

j= int.Parse(textbox.text) //Error

which is correct because "0.0000" is not a numeric value.

The same happens with a executescalar method whe the result is 0

......
string mc= mycmd.executescalar().tostring();
......

after this mc is "0.0000" !!

TIA

'*****************
int j ;

j= Convert.ToInt32(textbox.text)
 
S

Santosh

Fanor said:
I have a textbox control bound to a integer field of a table.
Why when the value of the field is 0, the textbox. text show as "0.0000"
????
When I tried to cast this to a integer variable there is an error:

int j ;

j= int.Parse(textbox.text) //Error

which is correct because "0.0000" is not a numeric value.

The same happens with a executescalar method whe the result is 0

......
string mc= mycmd.executescalar().tostring();
......

after this mc is "0.0000" !!

TIA

'*****************
int j ;

j= Convert.ToInt32(textbox.text)
 
F

Fanor

Santosh said:
'*****************
int j ;

j= Convert.ToInt32(textbox.text)



Doesn't work because textbox.text = "0.0000" which is not a valid number!!
furthermore the field value is 0, so textbox.text should be "0" not
"0.0000"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top