Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. databinding to control.tag causes changes to dataset

databinding to control.tag causes changes to dataset

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Glen Harvy 0
    wrote on last edited by
    #1

    Hi, I currently do the following when closing a form containing editable databound controls (comboboxes mainly).. this.configBindingSource.EndEdit(); if ((bool)this.myDataSet1.HasChanges()) // do some stuff The problem is that if I bind a control's tag to a field in the datatable, the above condition is met even if there are no changes made to the form's controls at all. Even if I bind it to a label.tag, it still triggers a change to the datatable. Is there something I'm doing wrong? Thanks.

    Glen Harvy

    U 1 Reply Last reply
    0
    • G Glen Harvy 0

      Hi, I currently do the following when closing a form containing editable databound controls (comboboxes mainly).. this.configBindingSource.EndEdit(); if ((bool)this.myDataSet1.HasChanges()) // do some stuff The problem is that if I bind a control's tag to a field in the datatable, the above condition is met even if there are no changes made to the form's controls at all. Even if I bind it to a label.tag, it still triggers a change to the datatable. Is there something I'm doing wrong? Thanks.

      Glen Harvy

      U Offline
      U Offline
      Urs Enzler
      wrote on last edited by
      #2

      No you're not doing something wrong, but you have to know something about data binding: Whenever you bind something to a property (Tag in your case) that does not have a corresponding PropertyChanged event (TagChanged event in your case) then the data binding framework assumes that the value has changed. Therefore the value is written back to the data source even if the value hasn't changed. If this is the reason for your problem then you can: - define that the binding is only unidirectional (from data-source to control and not back). This can be defined somewhere, but I can't remember where (we don't use data binding anymore) - derive a class from that control and implement the TagChanged event - use something better than data binding (MVP)

      -^-^-^-^-^- no risk no funk ................... please vote ------>

      G 1 Reply Last reply
      0
      • U Urs Enzler

        No you're not doing something wrong, but you have to know something about data binding: Whenever you bind something to a property (Tag in your case) that does not have a corresponding PropertyChanged event (TagChanged event in your case) then the data binding framework assumes that the value has changed. Therefore the value is written back to the data source even if the value hasn't changed. If this is the reason for your problem then you can: - define that the binding is only unidirectional (from data-source to control and not back). This can be defined somewhere, but I can't remember where (we don't use data binding anymore) - derive a class from that control and implement the TagChanged event - use something better than data binding (MVP)

        -^-^-^-^-^- no risk no funk ................... please vote ------>

        G Offline
        G Offline
        Glen Harvy 0
        wrote on last edited by
        #3

        Thanks for that - in this case I'll handle the situation differently.

        Glen Harvy

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups