Hi im new to C# and I have a form with customer data on it. There is a combo box with the customer name and some address fields. When I select the customer name I would like the address field to be automatically updated from the customer table. Can anyone help me with the code for this. Thanks in advance.
MJV 0 Junior Poster in Training
Recommended Answers
Jump to PostAs LizR said, binding is the best approach, however you can manually locate the Customer in the table and populate the address text box.
…string custName = combobox.Text; DataRow[] addressInfo = custData.Select(string.Format("Customer='{0}'",custName)); if(addressInfo.Length > 0) { edStreet.Text = (string)addressInfo[0]["Street"]; edCity.Text = (string)addressInfo[0]["City"]; // and so on... }
All 3 Replies
Reply to this topic Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.