Databinding with DataView - AllowEdit not working

C

Chris

Hi,

I am creating a new dataview with from my dataset like so:

mydv = New DataView
mydv = ds.Tables("table1").DefaultView

then I bind my combo box to one of the fields:

cbo.DataBindings.Add("SelectedValue", ds, "field1")

This works fine, however when i set the dataview AllowEdit property to
false it has no effect, can anyone tell me why?? and how this can be
fixed?

Thanks

Chris
 
I

Ilya Tumanov [MS]

That's because CB does not use IBindingList interface to bind, so it's
unaware of IBindingList.AllowEdit.
At the same time AllowEdit is not enforced by DataView (which you probably
don't want anyway as enforcing it would throw).
It's sort of a "suggestion" to whatever's using IBindingList interface not
to change anything.

If you don't want this value to be changed, disable combo box instead.
That makes sense as user won't be confused by the fact this value can be
changed, but never makes it to the data base.

Alternatively, set SelectedValue manually instead of using binding.

Best regards,

Ilya


This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top