We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

IntegerTextBox binding

What''s the best way to bind a DataView to an IntegerTextBox? If I do this: DataBindings.Add ("BindableValue", dataView, fieldName); Then, I''m able to bind to the dataView when the value happens to be DBNull which is handy and necessary but something seems to be happening during validation and the underlying dataset never seems to detect a change. Are there any tricks to binding to the BindableValue property? If I do this: DataBindings.Add ("IntegerValue", dataView, fieldName); I can change data and things work until I bind to a value that happens to be DBNull. Then I get an exception with the message: "Object cannot be cast from DBNull to other types." So, it seems like the BindableValue is the property to bind to but am I missing something? Thanks in advance, Mark

15 Replies

AR Anupama Roy Syncfusion Team April 3, 2006 12:14 PM UTC

Hi Mark, Are you using Essential Studio version 4.1? In 4.1,there is a known issue related to this.Please let me know so that I can give you more information based on this. Thanks for choosing Syncfusion. Regards, Anu.


AD Administrator Syncfusion Team April 3, 2006 02:29 PM UTC

Hi Anu, Yes, I''m using 4.1. Would the same issue exist for PercentTextBox, DoubleTextBox? Thanks for the reply, Mark > >Hi Mark, > >Are you using Essential Studio version 4.1? In 4.1,there is a known issue related to this.Please let me know so that I can give you more information based on this. > >Thanks for choosing Syncfusion. > >Regards, > >Anu. >


AR Anupama Roy Syncfusion Team April 4, 2006 01:29 PM UTC

Hi, Could you please set NumberGroupSeparator to String.Empty and see whether your exception is thrown or not.Also please let me know whether you have set UseNullString as true. Thanks, Anu.


MA Mark Atkinson April 6, 2006 08:07 PM UTC

Hi Anu, I changed the NumberGroupSeperator to String.Empty and I still get the same result when binding to the BindableValue property. An exception doesn''t get thrown, rather the value doesn''t get set in the underlying dataset. I also tested using the UseNullString value set as false and true: same result. I''ll try binding to the IntegerValue and see if there''s any difference. > >Hi, > >Could you please set NumberGroupSeparator to String.Empty and see whether your exception is thrown or not.Also please let me know whether you have set UseNullString as true. > >Thanks, > >Anu. > >


AR Anupama Roy Syncfusion Team April 7, 2006 01:24 PM UTC

Hi Mark, I am including a sample that has Databinding done with all our TextBox controls including IntegerTextBox and it worked fine with my suite. Could you please run this at your end and let me know how it goes?I have included the mdb file along the project sample Thanks, Anu.


MA Mark Atkinson April 13, 2006 05:59 PM UTC

Hi Anu, Thanks for the suggestions and source code. Binding to the IntegerValue (and setting those other properties) worked well initially until I needed to do something like this: DataBindings[dataView].SuspendBinding(); dataView.RowFilter = GetFilter(); DataBindings[dataView].ResumeBinding(); ...then, if the underlying data in the current row in the dataview had an integer field whose value is DBNull then exceptions were thrown. Recently I started using the new .NET BindingSource class and when I do some filtering and synching on the dataView that the BindingSource is bound to I get the same kinds of exceptions when I then do this: bindingSource.ResetBindings (false); ...the exception I get is: "DataBinding cannot find a row in the list that is suitable for all bindings". Again, if I change the binding property from IntegerValue to BindableValue then I have the issue of not being able to commit the changed value to the underlying data. I think I have an idea what is happening - the data really wants to be bound to an "integer-able" value. It''s almost as if the binding from the source to the control should be BindableValue, but the binding from the control to the source should be IntegerValue. Mark >Hi Mark, > >I am including a sample that has Databinding done with all our TextBox controls including IntegerTextBox and it worked fine with my suite. >Could you please run this at your end and let me know how it goes?I have included the mdb file along the project > >sample > > >Thanks, > >Anu. >


AR Anupama Roy Syncfusion Team April 17, 2006 12:55 PM UTC

Hi Mark, Sorry for the delay in response. I will investigate on integerTextBox issue and let you know about this.Do you see the same issue with other TextBoxes also? Please let me know regarding this. Thanks for your interest in Syncfusion products. Regards, Anu.


AR Anupama Roy Syncfusion Team April 17, 2006 01:53 PM UTC

Hi Mark, I tried the following code inorder to reproduce the issue. this.BindingContext[view].SuspendBinding (); this.view.RowFilter= "Amount =''8''"; this.BindingContext[view].ResumeBinding (); Could you please clarify where exacatly you mention your codings with respect to my previous sample.It would be appreciable if you can modify the previous sample and update us. Sorry for any inconvienience caused. Regards, Anu.


MA Mark Atkinson April 21, 2006 10:22 PM UTC

It''s really the same problem again. In the code you sent me, the field that''s bound to the IntegerTextBox control always has a value. In fact, the field in the database has a default value. As soon as one of those values is null (DBNull) your code will throw an exception ("Object cannot be cast from DBNull to other types.") so binding to the IntegerValue in the code you sent will work as long as all the rows in the table for that field have non-null values. I made some modifications to the mdb file (added some rows and got rid of the default value in the Amount field) and you can try it with the sample app. I really need to be able to bind to null values but how effective is the BindableValue property? > >Hi Mark, > >I tried the following code inorder to reproduce the issue. > >this.BindingContext[view].SuspendBinding (); >this.view.RowFilter= "Amount =''8''"; >this.BindingContext[view].ResumeBinding (); > >Could you please clarify where exacatly you mention your codings with respect to my previous sample.It would be appreciable if you can modify the previous sample and update us. > >Sorry for any inconvienience caused. > >Regards, > >Anu. > >

CurrencyDataBinding0.zip


AR Anupama Roy Syncfusion Team April 24, 2006 01:45 PM UTC

Hi Mark, Sorry for the confusion. You need to set BindableValue property itself in your scenario.Also you should set UseNullString property to true as shown below. this.integerTextBox1.DataBindings.Add ("BindableValue",view ,"Amount"); this.integerTextBox1.UseNullString =true; this.integerTextBox1.NullString=""; But in your version (4.1), we have a bug that when UseNullString property is used, IntegerTextBox will not be allowing values to be entered . This issue is resolved internally and the fix for this will be included with our upcoming release 4.2 due in another few days. For now you can test the above given codings for a DoubleTextBox and see whether the issue is resolved or not. Sorry for any inconvienience caused and Thank you for your patience. Regards, Anu.


MA Mark Atkinson April 24, 2006 04:03 PM UTC

Thanks Anu! I appreciate the feedback on this issue.


MA Mark Atkinson May 23, 2006 02:55 PM UTC

I didn''t see a note of this in the list of 4.2 features and fixes, but has this issue been resolved for 4.2? Thanks, Mark >Thanks Anu! >I appreciate the feedback on this issue.


AR Anupama Roy Syncfusion Team May 26, 2006 09:52 AM UTC

Hi Mark, In release notes it has been mentioned under IntegerTextbox Category - Fixes Thanks, Anu. >I didn''t see a note of this in the list of 4.2 features and fixes, but has this issue been resolved for 4.2? > >Thanks, >Mark > >>Thanks Anu! >>I appreciate the feedback on this issue.


AD Administrator Syncfusion Team June 7, 2006 06:28 PM UTC

OK, I have the latest Syncfusion 4.2 libraries and I''m still having great difficulty binding the BindableValue property of an IntegerTextBox to an integer field in a DataView. I have these properties set: NullString = ""; UseNullString = true; ...and I''m doing this type of binding: DataBindings.Add ("BindableValue", dataView, "MyIntField"); When I type a new value into the IntegerTextBox and then set focus in another control and have a look at the controls Validated event handler, I can see that the controls text is correct but the data source hasn''t been updated. So, when I move to a different record and then back again, the IntegerTextBox displays the old value - the new value never seems to get updated - as if using BindableValue only allows one way binding to the control. I''ll see if I can''t create a small project to send to you. >Hi Mark, > >In release notes it has been mentioned under IntegerTextbox Category - Fixes > >Thanks, > >Anu. > > > >>I didn''t see a note of this in the list of 4.2 features and fixes, but has this issue been resolved for 4.2? >> >>Thanks, >>Mark >> >>>Thanks Anu! >>>I appreciate the feedback on this issue.


AD Administrator Syncfusion Team June 7, 2006 08:42 PM UTC

I created a simple project and was able to reproduce my issue. The basic issue is the trouble with binding an IntegerTextBox''s BindableValue property. In the attached zip file, you can grab the small project I made and see that when the value is changed in the IntegerTextBox that uses the BindableValue to bind with, that the value never really gets changed. you can change that value and then click on some record in the grid, click back to the original record and the value is back to the original. This doesn''t happen when the IntegerValue property is bound. However, the IntegerValue has the obvious problem of not being able to bind to values of DBNull. >OK, I have the latest Syncfusion 4.2 libraries and I''m still having great difficulty binding the BindableValue property of an IntegerTextBox to an integer field in a DataView. > >I have these properties set: >NullString = ""; >UseNullString = true; > >...and I''m doing this type of binding: >DataBindings.Add ("BindableValue", dataView, "MyIntField"); > >When I type a new value into the IntegerTextBox and then set focus in another control and have a look at the controls Validated event handler, I can see that the controls text is correct but the data source hasn''t been updated. So, when I move to a different record and then back again, the IntegerTextBox displays the old value - the new value never seems to get updated - as if using BindableValue only allows one way binding to the control. > >I''ll see if I can''t create a small project to send to you. > > >>Hi Mark, >> >>In release notes it has been mentioned under IntegerTextbox Category - Fixes >> >>Thanks, >> >>Anu. >> >> >> >>>I didn''t see a note of this in the list of 4.2 features and fixes, but has this issue been resolved for 4.2? >>> >>>Thanks, >>>Mark >>> >>>>Thanks Anu! >>>>I appreciate the feedback on this issue.

intbinding.zip

Loader.
Live Chat Icon For mobile
Up arrow icon