我从不使用 linq to SQL,但在实体框架中我需要做这样的事情:
protected void ObjectDataSource_Updating(object sender, ObjectDataSourceMethodEventArgs e)
{
// Declaring the Entity context
AvalonEntities db = new AvalonEntities();
// In updating méthod of a ObjectDataSource the "e" arg is my customer, so i grab this
customer cus = (customer)e.InputParameters[0];
// say that i have a DropDown to select the account ...
// I Get de DropDown and get your SelectedValue.
DropDownList ddlAccount = (DropDownList)FormView1.FindControl("ddlAccount");
// Whit the value i declare a new account
account ac = new account () { id_account = int.Parse(ddlAccount.SelectedValue) };
// and associate it to Customer
cus.account = ac;
我希望这有帮助