views:

32

answers:

1

I have a table (EmployeeID,EmployeeName,ManagerID) How can I create a sqldatasource to include the ManagerName from the EmployeeName given EmployeeID = ManagerID? In my gridview after dragging a dropdownlist what bindings should I do to display the managerName? Is it possible to use it without writing custom select,insert,delete,update? If not what are the steps I need to do to write the whole thing i.e. custom grid and source?

Thank you very much

A: 

SQL datasource controls just allow you to easily wire up asp.net databound controls to datasources. You still have to write the correct SQL to do the relevent joins and get the data you require. e.g. you would have to write a sql commaind something like:

SELECT EmployeeTable.EmployeeName, ManagerTable.ManagerName
FROM EmployeeTable
INNER JOIN ManagerTable ON EmployeeTable.ManagerID=ManagerTable.ManagerID
WHERE EmplyeeTable.EmployeeID = @EmployeeID
Ben Robinson