I know what the problem is with updating the foreign key, I just can't seem to make it work.
I tried both the current code, and the line that is commented out.
Sponsorship mySponsorship = Repository._context.Sponsorships.SingleOrDefault<Sponsorship>((Sponsorship obj) => obj.id == int.Parse(editId) ? true : false);
        mySponsorship.Name = txbSponsorshipTitle.Text.Trim();
        DataClassesDataContext db = new DataClassesDataContext();
        // Don't assign just the id
        Event myValue = db.Events.Single(x => x.EventId == int.Parse(dropEvent.SelectedValue));
        int myEvent = myValue.EventId;
        //int myEvent = db.Events.Single(x => x.EventId == int.Parse(dropEvent.SelectedValue)).EventId;
        mySponsorship.EventId = myEvent;
        mySponsorship.Price = decimal.Parse(txbPrice.Text);
        mySponsorship开发者_开发技巧.description = venuEdit.Content;
        Repository._context.SubmitChanges();
        Response.Redirect("Sponsorshiplisting.aspx");
try to assign the event object it self not the EventID
Event myValue = db.Events.Single(x => x.EventId == int.Parse(dropEvent.SelectedValue));
mySponsorship.Event = myValue ;
and you may consider that mySponsorship and event must come from same datacontext otherwise LINQ will create a new identical Event entity to the one you assigned and insert it to database 
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论