-3

everybody.

I don't know how to solve this problem. I have a table Employees with three columns id int primary key, first_name varchar not null, last_name varchar not null.

Also, I have table Product which consist of id_Product primary key, name varchar not null, id_emp int not null which is foreign key.

On web form, I have one combobox that present id_emp column which contain all first_name and last_name from table Employees. When I select certain value from combobox I have to insert in table Product. I don't have any idea how to put first_name and last_name from table Employees in combobox.

Note: When you insert data first_name and last_name from combobox, you should get the same value in id_emp such as value in id column in table Employees.

I hope so that I don't confuse you. I tried to present my problem on simple way.

Michelle
  • 1
  • 1
  • Welcome to Stack Overflow! Please edit your question to include some code that you've already written: https://stackoverflow.com/help/how-to-ask – TrevorBrooks Aug 24 '17 at 19:11
  • On click on combo box sent postback and in postback send the id and what other information you want.. based on employee id insert things you want in product table. – nikunjM Aug 24 '17 at 19:13
  • I don't understand how to insert values from two columns in combo box. – Michelle Aug 24 '17 at 19:19
  • When user clicks on combo box get the value of selected combo box using jquery and pass to ajax ... – nikunjM Aug 24 '17 at 22:44
  • I don't know how to use jquery and ajax. – Michelle Aug 25 '17 at 09:16

1 Answers1

0

1) How to populate Combo box How to populate c# windows forms combobox?

2) How to do postback in dropdown https://asp-net-example.blogspot.com/2009/03/how-to-use-dropdownlist-autopostback.html

<asp:DropDownList ID="ddlGroupNameFilter" 
    runat="server" 
    AutoPostBack="true" 
    AppendDataBoundItems="true" 
    OnSelectedIndexChanged="ddlLeadgroupName_SelectedIndexChange">
</asp:DropDownList>

3) Another way around is to use javascript or jquery to get selected value and append values to postback. What is the meaning of __doPostBack function, and when is it used?

function getSelectedvalue(){
    var btn = document.getElementById("<%= btn.ClientID %>");
    __doPostBack('btn', '');
}

4) in codebheind somemethod will be there which will does insert for you

nikunjM
  • 560
  • 1
  • 7
  • 21