Calulated fields changes control values back to original


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Calulated fields changes control values back to original

  1. #1
    Jeff Guest

    Calulated fields changes control values back to original


    I am having major issues with databinding of row data returned via SQL Server
    2000 to user controls. As background, I'm binding controls via the designer
    to strongely-typed datasets.

    Example 1 - Calulated fields changes control values back to original values

    I have a data row which is bound to various controls (textboxes, comboboxes,
    etc.). One control is a bound combobox which has a calulation routine fired
    on the leave event. If I change the combobox (i.e combobox.valueselected)
    and in the calculation routine update a calculated value in the same row,
    the combox.valueselected goes back to the original value!?

    Dim dr As DataRow = Me.myDateset.myTable.Rows(Me.BindingContext(Me.myDataset,
    "myTable").Position)
    dr("calculatedCost") = totpc <--this causes combobox to change back to
    original value?
    Me.txtCalcCost.Text = totpc.ToString

    If I don't update row manually and just update bound cost box with just

    Me.txtCalcCost.Text = totpc.ToString

    The calculated cost in the row is not updated and thus not saved! What makes
    this worse is that it is very inconsistant. Sometimes this seems to work
    sometimes not. Is there a rule about changing bound row data? I am also wondering
    if this behavior is event related. I've noticed other problems trying to
    format control values on Leave and Enter events. So I've used GotFocus and
    LostFocus events instead.

    Any ideas or suggestions appreciated! I have other examples and will put
    them up for discussion when I get I chance.

    Thanks!!




  2. #2
    Kathleen Dollard Guest

    Re: Calulated fields changes control values back to original

    Jeff,

    There are some problems with binding related to underlying exceptions. Catch
    all exceptions in the CLR and see if anything pops up.

    If not, are you using a view? If so, if you reset the view to the underlying
    table, does it change anything?

    Kathleen

    "Jeff" <jeff@asifalcon.com> wrote in message news:3d7cf01d$1@10.1.10.29...
    >
    > I am having major issues with databinding of row data returned via SQL

    Server
    > 2000 to user controls. As background, I'm binding controls via the

    designer
    > to strongely-typed datasets.
    >
    > Example 1 - Calulated fields changes control values back to original

    values
    >
    > I have a data row which is bound to various controls (textboxes,

    comboboxes,
    > etc.). One control is a bound combobox which has a calulation routine

    fired
    > on the leave event. If I change the combobox (i.e combobox.valueselected)
    > and in the calculation routine update a calculated value in the same row,
    > the combox.valueselected goes back to the original value!?
    >
    > Dim dr As DataRow =

    Me.myDateset.myTable.Rows(Me.BindingContext(Me.myDataset,
    > "myTable").Position)
    > dr("calculatedCost") = totpc <--this causes combobox to change back to
    > original value?
    > Me.txtCalcCost.Text = totpc.ToString
    >
    > If I don't update row manually and just update bound cost box with just
    >
    > Me.txtCalcCost.Text = totpc.ToString
    >
    > The calculated cost in the row is not updated and thus not saved! What

    makes
    > this worse is that it is very inconsistant. Sometimes this seems to work
    > sometimes not. Is there a rule about changing bound row data? I am also

    wondering
    > if this behavior is event related. I've noticed other problems trying to
    > format control values on Leave and Enter events. So I've used GotFocus and
    > LostFocus events instead.
    >
    > Any ideas or suggestions appreciated! I have other examples and will put
    > them up for discussion when I get I chance.
    >
    > Thanks!!
    >
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center