Hi,
I'm trying to delete a record from the RadGrid.
So i'm handling the ondeletecommand like this:
The code above works fine, but this is not an easy way to get the appointmentID.
Unfortunately i can't the following code to work:
Because the dataitem seems to be null all the time??
Is there an explanation for this?
I'm trying to delete a record from the RadGrid.
So i'm handling the ondeletecommand like this:
protected void AppointmentsGrid_DeleteCommand( object source, GridCommandEventArgs e ) |
{ |
DALDataContext dc = new DALDataContext(); |
int appointmentID = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["AppointmentID"]; |
dc.Appointments.DeleteOnSubmit(dc.GetAppointmentByID(appointmentID)); |
dc.SubmitChanges(); |
AppointmentsGrid.DataBind(); |
} |
The code above works fine, but this is not an easy way to get the appointmentID.
Unfortunately i can't the following code to work:
DALDataContext dc = new DALDataContext(); |
vw_Appointment appointment = (vw_Appointment)e.Item.DataItem; |
dc.Appointments.DeleteOnSubmit(dc.GetAppointmentByID(appointment.AppointmentID)); |
dc.SubmitChanges(); |
Because the dataitem seems to be null all the time??
Is there an explanation for this?