PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Help to load table to a textbox when selecting in combobox with connection to anothe-VBForums
Results 1 to 2 of 2

Thread: Help to load table to a textbox when selecting in combobox with connection to anothe

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2018
    Posts
    1

    Help to load table to a textbox when selecting in combobox with connection to anothe

    Well I have a combobox connected to a database, then I want that when selecting an item I upload another table to a textbox, for example:

    I have 2 table, Subject and credit, then I want that when selecting the subject, I load the credit in a textbox.

    Heee tried many ways but I can not do it, thanks!

    And forgive my bad English, thank you for the time given

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,409

    Re: Help to load table to a textbox when selecting in combobox with connection to ano

    Unless you have a reason not to, I would suggest that you execute a single query that joins the two database tables, so you can populate a single DataTable with all the data and then bind that to both controls. If you bind both controls then the TextBox will be populated automatically when you make the selection in the ComboBox. E.g.
    csharp Code:
    1. myComboBox.DisplayMember = "NameOfColumnToDisplayInComboBox";
    2. myComboBox.ValueMember = "NameOfPrimaryKeyColumn";
    3. myComboBox.DataSource = myDataTable
    4. ;
    5.  
    6. myTextBox.DataBindings.Add("Text", myDataTable, "NameOfColumnToDisplayInTextBox");
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width