asp.net - Asp .Net LINQ to SQL Databinding, do a "lookup" without a lookup table? -


say have employee table. each employee has unique id. 1 of columns in table managerid, corresponds employee. when binding employee's data gridview, want display manager's name, not id. if had lookup table mangers <%# eval("lu_managers.managername") %>, don't have such table, nor want make one/keep track of it/update everytime new manager added or removed.

currently in onrowdatabound call e.row.cells[1].text = getfullnamefromemployeeid(convert.toint32(e.row.cells[1].text)); seems messy me.

is there way without using codebehind? or less efficient have now?

you need join employee table again manager

select    employee.*,   manager.firstname managername   tblemployee employee   join tblemployee manager     on employee.managerid = manager.pkemployeeid  

edit: can translated linq:

var q =   employee in db.tblemployee  join manager in db.tblemployee    on employee.managerid equals manager.pkemployeeid  select new  {    employee = employee,    managername = manager.firstname  }; 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -