DataList
Hi, how can i use a radiobutton control in the DataList? The binding doesn't work.
Thank you
I use this binding command: Me.AddBinding(ctl, "checked", ctl.Name)
As I recall, property names are case-sensitive. If you specify Checked (with an uppercase C) it should work. Since you're using the ctl.Name property for the field name, you might also check that it is spelled correctly and is using the same case as the underlying field name as well.
The names are correct. After the bindings i get a correct value of radiobutton. I can set the radiobutton from false to true but not from true to false. When i use the new row for new datas then i get not a next new row (that works without radiobutton correct) and when i go out the row i get a error from the TemplateControls.cs, Line 681: control.DataBindings.Add(b); {"Ein Objekt kann nicht von DBNull in andere Typen umgewandelt werden."}
I hope you understand me. My englisch is not so good.
Thank you
The same problem have it with the checkboxes.
From the translation of the error message it looks like your field is nullable and the current value when bound is null. Try setting the FormattingEnabled and NullValue properties on the binding which should handle it. FormattingEnabled allows type conversion and formatting to occur when setting the control value and NullValue tells it what to use as a default when the value is null.
Me.AddBinding(ctl, "checked", ctl.Name)
ctl.Bindings(0).FormattingEnabled = True
ctl.Bindings(0).NullValue = False
It's possible you may need to add Binding.Parse and Binding.Format event handlers instead to handle the conversion to/from null when formatting and storing the value.
Thank you for your Support My Solution:
Me.AddBinding(ctl, "checked", ctl.Name,, True, AddressOf format_event)
Sub format_event(sender As Object, cevent As ConvertEventArgs) sender.FormattingEnabled = True sender.NullValue = False End Sub
Me.AddBinding(ctl, "checked", ctl.Name, True, AddressOf format_event)