0
我有這個使用JOIN的EF數據源的RadGrid,在查詢中使用JOIN時更新實體
var result = db.Programmes.Join(db.Faculties, prog => prog.FacultyID, fac => fac.ID,
(prog, fac) => new {
ID = prog.ID,
FacultyID = prog.FacultyID,
FacultyText = fac.FacultyName_mk,
StudyLevelID = prog.StudyLevelID,
Ects = prog.Ects
}).ToList();
RadGrid1.DataSource = result;
到目前爲止這麼好。我有正確的數據顯示。
問題來了,當我想插入一個新的項目(程序)或更新現有的例如
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
{
GridEditableItem item = e.Item as GridEditableItem;
// get the ID
Int32 id = (Int32)item.GetDataKeyValue("ID");
// get the current record
var record = db.Programmes.Where(r => r.ID == id).FirstOrDefault();
//update entity's information with what was entered in the RadGrid
item.UpdateValues(record);
db.SaveChanges();
// close the edit form
RadGrid1.MasterTableView.ClearEditItems();
}
這個東西更新除了FacultyID應該從RadComboBox控件採取的所有列;
<EditItemTemplate>
<telerik:RadComboBox runat="server" ID="cmbFacultyID" />
</EditItemTemplate>
我從ItemDataBound中出價組合,它從Faculties實體讀取。
我該如何更新從此ComboBox中讀取FacultyID的程序表?
謝謝你這麼多