PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET numeric fied

Reply

numeric fied

 
Thread Tools Rate Thread
Old 30-06-2003, 11:45 AM   #1
Ced
Guest
 
Posts: n/a
Default numeric fied


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


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

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