-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.

5
  • Welcome to Stack Overflow! Please edit your question to include some code that you've already written: stackoverflow.com/help/how-to-ask Commented Aug 24, 2017 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. Commented Aug 24, 2017 at 19:13
  • I don't understand how to insert values from two columns in combo box. Commented Aug 24, 2017 at 19:19
  • When user clicks on combo box get the value of selected combo box using jquery and pass to ajax ... Commented Aug 24, 2017 at 22:44
  • I don't know how to use jquery and ajax. Commented Aug 25, 2017 at 9:16

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

The question is tagged asp.net-mvc, not web forms!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.