Hi,
I have 2 tables Employee and Works_On.While assigning work to employee i selected employee name in the drop down list.While storing those details in the works_on table i should store emp_id in the place of employee name.
In c# for drop down list i used sqldatasource and selected emp_name field from employee table.How to return emp_id.Do i need to implement it in the coding or in the properties?
Loading
Vishal GilbilePosted Mar 11, 2013, 12:49 AM
While binding the employee table data to dropdownlist you need to set the following properties.
dropdownlist1.DataMember=dropdownlist1.DataValueField="EmpId";
dropdownlist1.DataTextField="EmpName";
And whenever you are retrieving the value.
string id=dropdownlist1.SelectedValue.
Hope that solves your problem.
With Regards,
Vishal Gilbile.
sita kPosted Mar 12, 2013, 12:36 AM