srs2001 Posted September 2, 2005 Posted September 2, 2005 I have a textbox bound to a dataset field, should this text box automatically update with the data in that field? Yes/No? The book im working from basically has a drop down box that I select a country from, this then fills the dataset with customers from that country, and in the book the application then shows the first customers name from that country in the textbox(based on the book having the textbox bound to dataset->customer field, will auto update the textbox.text value with the data from the dataset) However when i recreate the example from the book the textbox field just stays empty upon selecting a country from the dropdown box. I know the dataset is ok as i can manually say textbox1.text = ds.etc etc Any advice would be much apprciate. my code for the drop down box change is as follows Private Sub cboCountry_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCountry.SelectedIndexChanged DsCustomers1.Clear() Dim con As New Component1 con.DsCustomers1 = con.FillCustomers(cboCountry.Text) positionindicator() MsgBox(con.DsCustomers1.Tables.Item("customers").Rows(1).Item(1).ToString) 'just a line te test dscustomers1 is filling End Sub code for fillcustomers as follows Public Function FillCustomers(ByVal country As String) As LearningVBdata.dsCustomers Dim ds As New LearningVBdata.dsCustomers Me.OleDbConnection1.Open() Me.OleDbDataAdapter2.SelectCommand.Parameters.Item (0).Value = country Me.OleDbDataAdapter2.Fill(ds) Me.OleDbConnection1.Close() Return ds End Function Quote
srs2001 Posted September 2, 2005 Author Posted September 2, 2005 I bound them by going to properties of the textbox->data->databindings->setting the tag to = the relevent field The dataset selected at that point is the dataset that i have pulled onto the bottom of my form by going to the toolbox and selecting dataset, then choosing the dataset that i setup in my component. Quote
srs2001 Posted September 2, 2005 Author Posted September 2, 2005 (edited) my thinking is my problem may be somewhere related to which dataset im filling, in my drop down i create a new component called con, and im filling the dscustomers of con. Now would that be a different dataset from what i could select going to the toolbox and dragging a dataset across and choosing one from the component. (edited through my own testing i now know that con.dscustomers is different to selecting the dscustomers from the toolbox, i guess the question is how do i fill the dataset from the toolbox, because if i do say component1.dscustomers.fillcustomerset, i'll get a non shared item error) (And I still wanna know YES or NO, should the textbox auto update its contents with that of a dataset if it is bound to it through the textbox->data->databindings->setting the tag to = the relevent field method?) Edited September 2, 2005 by srs2001 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.