2013-01-31 65 views
0

因此,在此頁面中,它將顯示當前subcontractors在這個特定BOQ上工作的列表。這存儲在'allSubContractors'2列表,使用下拉菜單選擇1個列表中的剩餘值

這顯示爲屏幕上的列表。然後,我想添加一個下拉框,允許用戶選擇任何剩餘的分包商並將其添加到列表中。

到目前爲止,第一部分工作,在BOQ顯示屏上工作的當前子附件工作列表,但對於下拉,我已經完全與我想要的相反。 拖放顯示當前分包商的相同列表,我想要剩下的列表中。

我使用:

`List<string> allSubContractors = new List<string>(); 
     ClarkeDBDataContext db = new ClarkeDBDataContext(); 
     allSubContractors = (from BoqSUBContractors in db.BOQ_SubContractors 
          where BoqSUBContractors.Bill_Of_Quantity_id == this.boqId 
          select BoqSUBContractors.Sub_Contractor.Company_Name).ToList(); 

     repeaterShowSubContractorName.DataSource = allSubContractors; 
     repeaterShowSubContractorName.DataBind(); 


    List<Sub_Contractor> availableSubContractors = new List<Sub_Contractor>(); 
    ClarkeDBDataContext db1 = new ClarkeDBDataContext(); 
    availableSubContractors = (from sc in db1.Sub_Contractors 
           from bsc in db1.BOQ_SubContractors 
           where sc.id == bsc.Sub_Contractor_id 
           && bsc.Bill_Of_Quantity_id == this.boqId 
           select sc).ToList(); 

    DropDownListSubContractors.DataSource = availableSubContractors; 
    DropDownListSubContractors.DataBind(); 

我嘗試類似:

List<Sub_Contractor> availableSubContractors = new List<Sub_Contractor>(); 
    availableSubContractors = (from sc in db.Sub_Contractors 
           select sc.id).ToList() 
           .Except(allSubContractors); 

但諾伊喜悅,有什麼建議? Thaks

回答

1

如果你嘗試

List<Sub_Contractor> availableSubContractors = 
(
    from sc in db1.Sub_Contractors 
    join bsc in db1.BOQ_SubContractors 
    on sc.id equals bsc.Sub_Contractor_id 
    where bsc.Bill_Of_Quantity_id equals this.boqId 
    select sc 
).ToList(); 

+0

謝謝你的回覆,但試過了,但是第三行裏面聲明bsc.Sub_Contractor_id是說bsc不在等於左邊的範圍內,考慮交換(我剛剛嘗試 - 也沒有喜悅)還有'where'狀態預計上下文關鍵字'等於' – John

+0

Yeap。將「==」更改爲「等於」,這是我的錯;) –