[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

Use listbox with SQL table data to fill remaining form controls upon selection

I have an SQL table, (tblFPDetail), that I would like to retrive data from and display this information in several textboxes on my form. My table has a foreign key (PCIDNum) with another table,(PCinfo). The PCInfo table contains a field, PCName. I would like to be able on my form to have a listbox that shows the PCName values of which the user would select the appropriate one. The remaining textboxes on the form would then fill with the related data from tblFPDetail. The user should then be able modify the values within the textboxes with data from tblFPDetail and select save from the toolstrip and have the values within tblFPDetail be modified.
Thanks in advance for any help!
0
IronDriver
Asked:
IronDriver
  • 2
1 Solution
 
Jorge PaulinoIT Pro/DeveloperCommented:
IronDriver,

You understand that what you are asking needs a lot of code to do. I will show you the basics and you can start working with that but it's difficult to explain everything in a post. I will show you how to retrive data from the form and populate the listbox (in the example I use a listview) but you can use that. Check this example that I post it yesterday http://www.experts-exchange.com/Microsoft/Development/.NET/Visual_Studio_.NET_2005/Q_23111538.html

Then what you have to do is when the user change the selection on the listview (listview selectedindexchange event) you read again from the db and populate the textboxes.

You can also use a datagridview control and bind using the available wizards. With this you can update/delete and insert direcly in the datagridview.
0
 
IronDriverAuthor Commented:
Thank you jp for the response...sorry so long to follow up. It has taken me a little while to actually get this to work as you have referenced in some of your prior comments. I have gotten the listview to work fine but that is about half the battle. I have included a diagram in PDF format the better illustrates what I am looking for. I may be headed about this in the wrong manner and if so feel free to let me know a simpler way...or if I am just wayyyyy off.   Thanks!
Simple-Table-Diagram.pdf
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
HI,

I have seen you Diagram but if you already filled the list the you can do the next step. When you populate a listview you should include a column with the ID. When you select the ID on the listview you do a select statement to the database and populate the fields. This is almoust the same as populate the listview but since it will retrieve only one field you will set the fields to the form textboxes.

After this you only need to build a update statement and save the data to the database.

I don't know wath you have so far and your dificulties so it's better if you expose them and show what you have so far.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now