How can i Validate infromation
Hi all
i have a question,
i´m using a data set with a buch of controls ( all bindable )
when i press my add new button i call the forms currenymanager.Addnew method,
so when i press Save Button, What should i do ?
1 Before i do the end current edit i should validate all the fields ?
2 do the current edit ?
if i do this it throws an dataexception but i don´t know how to treat the error
( The column that has the error of course, or a violation of primary key )
anyone could help me ?
ths
JSB
Ps: i don´t belive that i´m the only with this kind of problem, all the samples that i have see no one have validation .... ( too bad, microsoft doesn´t show how to validate information before update ) ....
when you call CurrencyManager.EndCurrentEdit it will fire off the Validating and (hopefully) the Validated Events for each control. You will need to write some code to validate each control (or one method that is handled by all your controls). Assuming all of those are successful, your EndCurrentEdit should work.
Here's the Event's definition from MSDN. It also has some example code: <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassvalidatingtopic.asp">Control.Validating Event</a>
thks for the help,
" when you call CurrencyManager.EndCurrentEdit it will fire off the Validating and (hopefully) the Validated Events for each control " i cannot put them to work ...
Hi have made an example, with a few textboxes. all with the validating and validate event,
and i create a dataset and bind them all.
create a currency manager and a few buttons (offcourse) ( add new, update delete and cancel )
each of those buttons, uses the currencymanager operations such as m_CurrencyManager.AddNew , etc ...
so,
when i press the button addnew and after i fill 2 of my 3 textboxes ( all 3 are required ), i press the button update ( m_CurrencyManager.EndCurrentEdit() ) and it didn´t fire the validate or validating events for them ....
What i´m doing wrong....
or it doesn´t work as i´m thinking ...
THks
JSB
Please Help ....