combo box
-
good morning, i create a table employee,in that table i have two columns empid,empname.i can create a form inthat i can use combo box and text box,combobox contains empid,id,if i can select a empid from the combobox the corresponding empname in the database that displays on the textbox.how can we do that?give me a better solution. thank u.(using ado.net & c#.net)
-
good morning, i create a table employee,in that table i have two columns empid,empname.i can create a form inthat i can use combo box and text box,combobox contains empid,id,if i can select a empid from the combobox the corresponding empname in the database that displays on the textbox.how can we do that?give me a better solution. thank u.(using ado.net & c#.net)
Hi Here's my suggestion.Having a service that returns an EmployeeName by a given EmployeeId, you can ask for EmployeeName by employeeId whenever you want. First I create an Interface:
public interface IEmployeeService { string GetEmployeeNameById(int emp_id); }
Then I implement it.According to your scenario I think that you can get an employee name when its needed(you don't have to load all names at once) Here's a possible implementation:public string GetEmployeeNameById(int emp_id) { var query=string.Format("SELECT emp_name FROM EmployeeTable WHERE emp_id={0}",empId); //Execute a database command and return its result ... }
Now I define a local variable in my form like this:... IEmployeeService employeeService=new MyEmployeeSrvice(); ...
And finally I handle the ComboBox SelectedItemChange event to set text of EmployeeName text box... empNameTextBox.Text=employeeService.GetEmployeeNameById(selectedId); ...
-
good morning, i create a table employee,in that table i have two columns empid,empname.i can create a form inthat i can use combo box and text box,combobox contains empid,id,if i can select a empid from the combobox the corresponding empname in the database that displays on the textbox.how can we do that?give me a better solution. thank u.(using ado.net & c#.net)
do like post above. remember that you dont edit the combobox, you edit the dataset the fill the combobox. i do that in sql server, you can do it as well.
nelsonpaixao@yahoo.com.br trying to help & get help