PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
numeric fied
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
numeric fied
![]() |
numeric fied |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I've designed an interface to encode some fields into a typed Dataset.
There's no problem for text fields but how can I do for numeric fields ? I've used Int32.Parse method because I got a compilator error but how can I handle empty fields or non numeric inputs ? DataSet1.PRORow dr = dataSet11.PRO.NewPRORow(); .... dr.PRO_SOCIETE = textBox1.Text; // text field dr.PRO_BOITE = Int32.Parse(textBox6.Text); // numeric field .... I plan to do this: if (textBox6.Text == "") dr.PRO_BOITE = DBNull.Value; else dr.PRO_BOITE = Int32.Parse(textBox6.Text); with : private void textBox6_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (!Char.IsDigit(e.KeyChar)) { e.Handled = true; // only digits } } Is there a better way to do this ? Thanks, Ced |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

