let's say i have an order and order details.
the view will contains the order fields, and a Telerik Grid for the details
i always maintain a reference of the Order in the session.
Session["Order"] = order;
and when the user add an order detail to the grid, I'm saving it in the Order reference.
public ActionResult Grid_AddDetail(OrderDetail orderDetail) {
(Session["order"] as Order).Details.Add(orderDetail);
}
the problem is when i need to update the row, how can i determine which detail in Order Details has been updated?
public ActionResult Grid_UpdateDetail(OrderDetail orderDetail) {
///how will i compare the element in the details, with the orderDetail?
(Session["order"] as Order).Details.IndexOf(orderDetail) = orderDetail;
}
the problem can be solved by adding a serial number column, and compare the incoming detail with the existed on in my reference, by overriding the Equal:
public overrid Equal(object obj){
return (obj as OrderDetail).Serial == this.Serial;
}
but i want the serial number column to be invisible, but if i do so, it will not be presented in the incomming detail.