CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2006
    Posts
    28

    Question text boxes reverting to pre edit values?

    I have written some code to get the data from a number of text boxes all named in the style txb_[column name]

    I want to write this data to a datatable.

    The text boxes were initially filled using a row 'aIndex' from the datatable, then the user can edit the data.

    When this code runs, the text boxes all revert to their initial values, regardless of any changes made to their contents during runtime.

    Code:
            'save data to table
    
            For Each c As Control In Me.MyPanel.Controls
                If c.Name.StartsWith("txb_") Then
                    col_Name = c.Name.Substring(4)
                    Select Case MyTable.Columns(col_Name).DataType.ToString ' check if it's a string
                        Case "System.String"
                            MyTable.Rows(aIndex)(col_Name) = c.Text
                        Case Else
                            Console.WriteLine(" Column " & col_Name & " is not a string")
                    End Select
                End If
            Next
    I want to update the table with the new data. Any ideas?

    TIA

    H
    I'm using .NET Framework 3.5

    I'm planning to be spontaneous tomorrow

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: text boxes reverting to pre edit values?

    Download the examples from here, and check them out.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured