Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Only updating first record

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Manchester, England
    Posts
    255

    Resolved [RESOLVED] [2005] Only updating first record

    I've got a ListView which is populated by a DataTable obtained from an XML data source.
    The application is being designed to allow the user to scroll through a list of items in the ListView, and display data in three TextBoxes that correspond with the selected item.
    Scrolling through the ListView and displaying the correct data in the TextBoxes is fine, however, I want the user to be able to edit the text boxes, press Save, and update the correct record.
    What I'm finding is that it ALWAYS updates the data associated with the first item in the ListView when it writes the data back to the XML file.
    Could anybody tell me what am I missing?
    At home - VB.NET 2005/2008 Express, Visual Web Developer 2005 Express
    At work - VS 2008 Standard (VB)
    .NET 2.0/3.5


    Visual Studio Express Learning Centre | How do I videos | MSDN VB Express Forum | MSDN VB Developer Centre

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [2005] Only updating first record

    What is your code to do the update?

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Only updating first record

    You really should be using a DataGridView rather than a ListView. You could bind the DataTable to a BindingSource and the BindingSource to both the grid and the TextBoxes. There would be no code and you'd be guaranteed of updating the correct record. You could even do away with the TextBoxes and let the user edit the data in the grid itself.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Manchester, England
    Posts
    255

    Re: [2005] Only updating first record

    DataGridView works much better - thanks for the suggestion.
    At home - VB.NET 2005/2008 Express, Visual Web Developer 2005 Express
    At work - VS 2008 Standard (VB)
    .NET 2.0/3.5


    Visual Studio Express Learning Centre | How do I videos | MSDN VB Express Forum | MSDN VB Developer Centre

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] [2005] Only updating first record

    I used to use ListViews in .NET 1.1 because I thought the DataGrid didn't fit with the rest of the UI. The DataGridView sure is easier to use than either the DataGrid or the ListView and it has a modern look that goes with the other standard controls.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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