Groups | Blog | Home
all groups > vb.net data > july 2004 >

vb.net data : Problems with Textbox, TabControl and DataBinding


Ken Tucker [MVP]
7/19/2004 7:17:06 AM
Hi,

Edit the value in the datasource instead of the textbox to
change it with code.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim strConn As String

Dim strSQL As String

Dim da As OleDbDataAdapter

Dim ds As New DataSet

Dim conn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)

da = New OleDbDataAdapter("Select * From Categories", conn)

da.Fill(ds, "Categories")

txtName.DataBindings.Add("Text", ds.Tables("Categories"), "CategoryName")



Dim dr As DataRow = ds.Tables("Categories").Rows(0)

dr.BeginEdit()

dr.Item("CategoryName") = "Hello World"

dr.EndEdit()

End Sub



Ken

----------------------

[quoted text, click to view]

Juanjo
7/19/2004 8:21:03 AM
Hi,

I have a form with one Tabcontrol who has two TabPages with two
Textboxes
binded to a DataSet. I have the next problem:

1-I change with code the text of TextBox1 in TabPage 1
(TextBox1.Text="Hello")
2-I click on TabPage 2.
3-I return to TabPage 1. Then, TextBox1 removes 'Hello' and puts the old
value.
4-But If I change de Text of TextBox1 directly (not by code changing
Text Property), It works fine.

What can I do?

Regards,
Juanjo.


AddThis Social Bookmark Button