G
Guest
Hey all,
I've the following code:
Dim _postBack As Boolean = False
Dim _ds As New DataSet1
Dim _dt As DataSet1.CustomersDataTable
Dim _dr As DataSet1.CustomersRow
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(_ds)
_dt = _ds.Customers
ListBox1.DataSource = _dt
ListBox1.DisplayMember = "ContactName"
ListBox1.ValueMember = "CustomerID"
_postBack = True
End Sub
Private Sub ListBox1_SelectedValueChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles ListBox1.SelectedValueChanged
If _postBack = True Then
MessageBox.Show("Finding customer...")
_dr = _dt.FindByCustomerID(ListBox1.SelectedValue)
TextBox1.Text = _dr.ContactName
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
_dr.ContactName = TextBox1.Text
MessageBox.Show(_dr.RowState.ToString)
End Sub
Why?, when I click the Button1, does the ListBox1_SelectedValueChanged run?
To recreate:
All you need is Northwind.
I used the SqlDataAdapter wizard
Generated a typedDataset(no instance)
I've the following code:
Dim _postBack As Boolean = False
Dim _ds As New DataSet1
Dim _dt As DataSet1.CustomersDataTable
Dim _dr As DataSet1.CustomersRow
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(_ds)
_dt = _ds.Customers
ListBox1.DataSource = _dt
ListBox1.DisplayMember = "ContactName"
ListBox1.ValueMember = "CustomerID"
_postBack = True
End Sub
Private Sub ListBox1_SelectedValueChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles ListBox1.SelectedValueChanged
If _postBack = True Then
MessageBox.Show("Finding customer...")
_dr = _dt.FindByCustomerID(ListBox1.SelectedValue)
TextBox1.Text = _dr.ContactName
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
_dr.ContactName = TextBox1.Text
MessageBox.Show(_dr.RowState.ToString)
End Sub
Why?, when I click the Button1, does the ListBox1_SelectedValueChanged run?
To recreate:
All you need is Northwind.
I used the SqlDataAdapter wizard
Generated a typedDataset(no instance)