After binding an Int32 a text box from on the fly table, get an error for blank in textbox 
Author Message
 After binding an Int32 a text box from on the fly table, get an error for blank in textbox

I am creating a table on the fly with an System.Int32 datatype and then bind
it to a text box.
As long as there is a number in there the textbox behaves ok.
As soon as it has blank value and try to leave the txtbox get a runtime
error
    Input string was not in a correct format.

Sample code

DataColumn dcexecid= new DataColumn(); //exec_id
dcexecid.DataType = Type.GetType("System.Int32");

dcexecid.ColumnName = "exec_id";

dcexecid.AllowDBNull = true;

dtSearch.Columns.Add(dcexecid);

txtSearchExecId.DataBindings.Add("Text",dtSearch,"exec_id");

any ideas



Thu, 07 Oct 2004 03:39:38 GMT  
 After binding an Int32 a text box from on the fly table, get an error for blank in textbox
Hi George,

It seems that the null string cannot be interpreted correctly in your case.  However, I could not reproduce the problem. When I clear the text or input non-numeric  text in
the textbox, the origianl valid numeric text is restored.

Can you provide me more info about your code? How does the complete code look like?

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Quote:


>Subject: After binding an Int32 a text box from on the fly table, get an error for blank in textbox
>Date: Sat, 20 Apr 2002 15:39:38 -0400
>Lines: 27
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

>Newsgroups: microsoft.public.dotnet.languages.CSharp
>NNTP-Posting-Host: wdext.wdsec.com 169.196.240.5
>Path: cpmsftngxa08!cpmsftngxa09!tkmsftngp01!tkmsftngp07
>Xref: cpmsftngxa08 microsoft.public.dotnet.languages.csharp:56075
>X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

>I am creating a table on the fly with an System.Int32 datatype and then bind
>it to a text box.
>As long as there is a number in there the textbox behaves ok.
>As soon as it has blank value and try to leave the txtbox get a runtime
>error
>    Input string was not in a correct format.

>Sample code

>DataColumn dcexecid= new DataColumn(); //exec_id
>dcexecid.DataType = Type.GetType("System.Int32");

>dcexecid.ColumnName = "exec_id";

>dcexecid.AllowDBNull = true;

>dtSearch.Columns.Add(dcexecid);

>txtSearchExecId.DataBindings.Add("Text",dtSearch,"exec_id");

>any ideas



Mon, 11 Oct 2004 12:01:02 GMT  
 After binding an Int32 a text box from on the fly table, get an error for blank in textbox
When I do it on one form, get the same result that you get.
The orginal has a login form, an mdi and then the form that creates the
error.
But we still have an issue by not allowing blank or null in a textbox.
You said that the original value appears that is say you enter 10 and
then try to leave it blank/null the 10 appears.
I do get the same results in a single form app.
However, it should stay null.
Any ideas how to make the textbox accept blank/nulls?
I know that if I switch from int to string will work but happens if an
application really needs null?

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Mon, 11 Oct 2004 22:34:43 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Bitmap Constructor (Int32, Int32, Int32, PixelFormat, IntPtr) [C#] ????

2. AutoGenerating Bound Text boxes.

3. ADO.NET (ComboBox, Text Box bindings and so on)

4. Problem with Getting Text in Combo Box

5. Getting text from a list box

6. Wrapping text in text box or edit box

7. Problem with Getting Text in Combo Box

8. Creating multiple text boxes and then getting the values

9. Problem adding record to blank Access Table using DAO

10. Blank text columns on ADO update

11. Replace multiple blanks with a single blank

12. Initializing An Edit box that holds an Integer Value to Blank instead of any value

 

 
Powered by phpBB® Forum Software