maybe I need to start over. Thx for the helpful links for the datagridview but I didn't really need to bring that up.
The essence of the problem is this: I use this method for 2 things: - to get the necessary data out of the database when adding a new record - to get the necessary data out of the database after I've updated a record
public void refreshReservationDetail()
{
_oReservationDetail = (from rd in _oReservation.tblReservationDetails
where rd.ReservationID == _oReservationObject.ID
select rd).ToList();
}
When I add a new record the new data is saved and loaded into the datagridview. So this works fine.
When I update an existing record (that is already shown in the datagridview) the altered content is also being saved properly but the method above is not giving me the saved data but still the old data. How come?
Here I save my data
//frmReservationDetail
public event dRefresh SavedActivity;
private void btnOk_Click(object sender, EventArgs e)
{
_oReservationDetail.ReservationDetailData.ReservationID = _oReservationDetail.ReservationObjectData.ID;
_oReservationDetail.ReservationDetailData.StartTime = Convert.ToDateTime(_oReservationDetail.ReservationObjectData.StartTime.Value.ToString("dd/MM/yyyy") + " " + _oDateTime[cboStartTime.getSelectedID()]);
_oReservationDetail.ReservationDetailData.EndTime = Convert.ToDateTime(_oReservationDetail.ReservationObjectData.StartTime.Value.ToString("dd/MM/yyyy") + " " + _oDateTime[cboEndTime.getSelectedID()]);
if (this.cboLanguage.SelectedItem != null)
{
_oReservationDetail.ReservationDetailData.LanguageID = this.cboLanguage.getSelectedID();
}
else
_oReservationDetail.ReservationDetailData.LanguageID = null;
if (this.cboTargetgroup.SelectedItem != null)
{
_oReservationDetail.ReservationDetailData.TargetgroupID = this.cboTargetgroup.getSelectedID();
}
else
_oReservationDetail.ReservationDetailData.TargetgroupID = null;
if (this.cboExcursion.SelectedItem != null)
{
_oReservationDetail.ReservationDetailData.ExcursionID = this.cboExcursion.getSelectedID();
}
else
_oReservationDetail.ReservationDetailData.ExcursionID = null;
_oReservationDetail.ReservationDetailData.Participants = int.Parse(this.txtParticipants.Text);
_oReservationDetail.ReservationDetailData.Leaders = int.Parse(this.txtLeaders.Text);
_oReservationDetail.ReservationDetailData.Remarks = this.txtRemarks.Text;
_oReservationDetail.save();
if(SavedActivity != null)
SavedActivity();
this.Close();
}
//clsReservationDetail
public void save()
{
int i = _oReservationDetail.ID;
if (_oReservationDetail.ID == 0)
{
_oReservation.tblReservationDetails.InsertOnSubmit(_oReservationDetail);
_oReservation.SubmitChanges();
}
_oReservation.SubmitChanges();
}