Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Binding Source EndEdit() Problem
 

Binding Source EndEdit() Problem

Hi all

i am developing a project and on one of the form i am having a very weird Problem.Here is the Detail

1) i have added new data source from the data menu and then designed this form by selecting detailView from data Source Window and Draged and Droped on to the form.

2) Atfer Few Days i added 4 more fields to the database and configed the data set accordingly and draged and droped new field to the form as well.

3)But one of the new fields is not being saved to the database (saving null).all the other 3 new fields are being saved Properly

4)After spending alot of time on it.I set a watch on that textbox and set breakpoints on save button cl;icked
and found that when bindingsource.EndEdit() method is called it clears the textbox value.Before this EndEdit Method is called that textBox contains the value but after the execution of the EndEdit method the textbox is cleared

Any Ideas y this is happeding ????
thanks


C# lover
sohail Khaliq  Wednesday, June 24, 2009 9:50 AM
When this happend to me, i had the wrong binding set on the textbox.

Verify that the DataBinding is on the TextProperty...

this .textBox1.DataBindings.Add("Text" , bindSrc, "Name" );


Please click 'Mark as Answer' on the post that helped you.
DamPee  Wednesday, June 24, 2009 11:51 AM

Try to check ValueType of property which binded to that Textbox.

BindingSourse try to update value from control (i.e. in urcase Textbox) to datasource, if it failed to convert the value as per
property then it clears Text of textbox.


NareshG  Wednesday, June 24, 2009 12:57 PM
hi

sorry cant fully understand your reply.I dont know what the problem is,Can you plzz suggest an solution to this problem


Thanks
C# lover
sohail Khaliq  Thursday, June 25, 2009 5:37 AM
hi

thanks for the reply


after getting your reply i checked the binding of the textbox but its fine

this .TelePhonetextBox.DataBindings.Add("Text" , applicantsBindingSource, "TelePhone_Previous",true );


i cant understand y this is happening ????


any suggestions????

thanks
C# lover
sohail Khaliq  Thursday, June 25, 2009 5:40 AM

Could you please tell me , what is the type of TelePhone_Previous ?

is it string ?

NareshG  Thursday, June 25, 2009 11:37 AM
yes Telephone_previous is a string type in my dataset and nvarchar(50) in my database

there shouldn't be any problem coz other fields of the table are saved only this one is Troubling me



C# lover
sohail Khaliq  Thursday, June 25, 2009 2:24 PM
"3)But one of the new fields is not being saved to the database (saving null).all the other 3 new fields are being saved Properly"


what are you doing to save null. ?

For this you have to set DataSourcenNullValue

Binding b = new Binding("Text", applicantsBindingSource, "TelePhone_Previous", true);

b.DataSourceNullValue =

b.DataSourceNullValue =

null;

this .TelePhonetextBox.DataBindings.Add(b );
NareshG  Friday, June 26, 2009 4:37 AM
Hi

I have the same problem, did you find and solution?
HenrikAn  Wednesday, July 29, 2009 11:55 AM

You can use google to search for other answers

Custom Search

More Threads

• Binding to a list of custom objects
• INSERT row into table without matching columns names
• Enter key problems Datagridview
• Cell Validating Event
• [C#]datagridview copy/paste entire rows
• DataGridView and trapping row changes
• Set and Get Files
• Binding a PictureBox Image to SQL Image Column - I must be missing something
• Binding to sub objects with datagridview
• Cannot Set properties for controls that are not visible