Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change grid update to textbox

Status
Not open for further replies.

Domino2

Technical User
Jun 8, 2008
475
GB
I am struggling to modify what is a gridview update to a textbox update. Because VB.Net is new to me, all the syntax appears back to front to me. Can someone advise me, thanks

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

' cb = New MySqlCommandBuilder(DataAdapter1)

' Dim i As Integer = DataAdapter1.Update(ds.Tables("Mycontacts"))

' MessageBox.Show("modify the number " & i.ToString & " rows")

End Sub


I can understand that the integer i is referencing the row of the gridview control, but how I apply this to a textbox containing a current record foxes me, as there is no reference to a record ID or index of the textbox itself I'm lost. In trial and error I found with the grid I could rem out the messagebox line and it still updated (having no yes/no split in the messagebox line. Having Dim i as integer followed by the update command is foreign language to my past VB6 knowledge. Appreciate it very much if someone could enlighten me. Thanks
 
I managed to get what I wanted:

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim inc As Integer
inc = 0
cb = New MySqlCommandBuilder(DataAdapter1)
ds.Tables("Mycontacts").Rows(inc).Item(1) = TextBox1.Text
DataAdapter1.Update(ds, "Mycontacts")
End Sub

The variable inc for the rows will be establshed later when selecting the data, it's shown here being given a hardcoded value. I looked around for ages to get reference help on textboxes, the whole world seems to give examples for grids holding data as opposed to what I thought databases exist around textboxes?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top