Results 1 to 7 of 7

Thread: Possible problem with data binding?

  1. #1

    Thread Starter
    Member Redeye44us's Avatar
    Join Date
    Apr 2003
    Posts
    50

    Possible problem with data binding?

    I have a Windows form for accounts/products. There are three tabs, the first (LIST) has a datagrid with account number and name, the second (EDIT) has text boxes for account data and a datagrid listing products, the third (PRODUCTS) contains textboxes for product data. The account table is bound to the datagrid on the LIST tab and the textboxes on the EDIT tab. The product table is bound to the datagrid on the EDIT tab and textboxes on the PRODUCTS tab. If I am on the PRODUCTS tab adding products, click the EDIT tab, then the PRODUCTS tab again to try adding more products, the new products are no longer going to the table. It's almost like the controls are no longer bound to the table. They don't give any error and the display shows the last product for that account prior to tabbing to EDIT screen. The only coding executed when changing tabs are for enabling/disabling buttons. Hope this all makes sence to somebody. Thanks for any help you can provide.

  2. #2
    Addicted Member
    Join Date
    Apr 2002
    Location
    California
    Posts
    160

    Must have code

    Got Code?
    Jason Moore

    Software Engineer, Database Architect, Web Designer

    (C#,VB/NET,ASP/NET,COLDFUSION,JAVASCRIPT,SQL)

    http://www.gatorstudios.com
    [email protected]

  3. #3

    Thread Starter
    Member Redeye44us's Avatar
    Join Date
    Apr 2003
    Posts
    50
    Here's the code
    Attached Files Attached Files

  4. #4
    Addicted Member
    Join Date
    Apr 2002
    Location
    California
    Posts
    160

    Data Binding Problem

    Well I looked through the code and could not find anything wrong with it from sight. If i where able to run the form without errors I might be of better use.

    One thing I can tell you is to set a breakpoint at the TabControl1_SelectedIndexChanged or at the individual TabPaint events. Then run the form investigate the variables in the locals and auto window. Basically run through the code step by step. I am not sure if you have a well understanding of the code, but if you do this should help.

    I tried to create STUBS of objects not available and blockqoute some of the lines that called objects not available. I was able to run the form but with many errors.

    Hope this helped.
    Jason Moore

    Software Engineer, Database Architect, Web Designer

    (C#,VB/NET,ASP/NET,COLDFUSION,JAVASCRIPT,SQL)

    http://www.gatorstudios.com
    [email protected]

  5. #5

    Thread Starter
    Member Redeye44us's Avatar
    Join Date
    Apr 2003
    Posts
    50
    I have put a breakpoint in the selectedindexchanged and checked out the locals. I am fairly new to vb.net, but can work my way through most problems. I was able to watch the cmproduct count adjust as I added products and could see the value of the product number change. Once it tabbed off and back on products tab, the data in locals followed what was showing on the screen. I may not be following the right variables to find the problem. What would you need to check out some more? The database, dataset...? I did notice that when I tabbed to the edit tab, the pointer for the product datagrid was not on the same row that was showing in products tab. Thanks for you Help!!!

  6. #6
    Lively Member Kenbuddy's Avatar
    Join Date
    Jul 2002
    Location
    Cypress, TX
    Posts
    96
    I have had similar problems where I update a .text or .tag property of a label, then switch tabs. The values that I just put in the .text or .tag properties just seem to vanish when switching tabs. The solution I have found is to update the property, and then immediately call the endcurrentedit method of the binding context to force an update of the underlying dataset. I am using the Component One C1DBNavigator control which exposes the bindingcontext property. However, I think (going from memory here because I am at my "real job" now where I don't do any programming) you can access the binding context of the form by using the following syntax:

    Code:
    me.bindingcontext(dsDataSetName, "tblDataTableName").endcurrentedit
    Again, I'm not 100% sure of the syntax, but it's something close to that. Anyway, just call that method before switching the tabs and it forces an update of the dataset that the controls are bound to. It might also be helpful to update the underlying database at the same time by using the update method of the data adapter.

  7. #7

    Thread Starter
    Member Redeye44us's Avatar
    Join Date
    Apr 2003
    Posts
    50
    Thanks for the input. The way I had it setup, the user has to hit a save button before they can select a different tab. The save does the endcurrentedit and updates the dataset. Since my last post, in a effort to simplify things, I have removed the tabs and put everything on one screen. I also removed the datagrid's used to list the accounts & products. Right now it's just textboxes and navigation buttons for accounts and textboxes and navigation buttons for products below that. I am running into the same problem if I add products then navigate to another account and then try to add more products. The first will work, everything after that fails. I'll double check the relation I have set between the tables to be sure it looks right. Thanks for you help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width