Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataBinding a CheckBox
Message
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
00715187
Message ID:
00715553
Views:
15
Hey Cathi,

I figured it had to be a known bug, cuz it was so obvious. I worked around it by not databinding the checkbox and handling it all manually. But I don't like that, so I'm messing around with other ways of handling it in our checkbox sub-class.

~~Bonnie


>Hi Bonnie,
>
>This is a known bug with checkboxes. Hopefully it will be fixed in the next version. The only work around I know of is to set a default value to false. You will lose the ability to have it set to NULL. Not much of a work around :(
>
>>Hi all,
>>
>>Sorry I haven't been answering many questions here lately ... I've been head-down in coding 24/7. <g> But I have a question that hopefully someone else will be able to answer.
>>
>>I have a control with a checkbox on it that I would like to bind to a boolean column in a DataSet. The DataSet is filled from a SQL Server table and it *does* allow NULLs in the column.
>>
>>I can't bind to the CheckState (blows up with an error about "Invalid cast from System.Boolean to System.Windows.Forms.CheckState"), so I'm binding to Checked (which seems right to me anyway). I've set the CheckBox.ThreeState = true (since the column *can* have a NULL value).
>>
>>I seem to be getting a problem though when I attempt to change the BindingContext.Position to a row that has a DBNull.Value in this column. I get no error that I can see, but the BindingContext.Postion just doesn't change ... it remains on whatever row it was already on rather than go to the row with the null value.
>>
>>What's up with that? Anyone know of a work-around or am I just doing things wrong?? (BTW, this behavior happens whether I have ThreeState either true or false).
>>
>>TIA,
>>~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform