I have a custom GridView control (inherits from system.web.ui.webcontrols.gridview) and I would like to control the TextBox value based on values โโrecently inserted by the user (the inserted values โโare not bound to the data source).
In Grid.DataBound, I can query the cells of one column to get the current maximum that I set in the TextBox.
int maxTimeSlot = grid.Rows.OfType<GridViewRow>().Max(r => int.Parse(r.Cells[1].Text));
After entering a new row, I have access to the "Insert" property of the Grid, which contains a list of all inserted rows so far, for example:
GridView.Inserts[0].NewValues & GridView.Inserts[0].OldValues
What I need to do is use this Insert list to get the maximum value again, but I'm trying to query NewValues.Values โโ(OrderedDictionaryKeyValueCollection) to get the value.
NewValues.Values.OfType<KeyValuePair<object, object>>().Select(r => r.Key == "timeslot").Max(t => (int)t.Value)
Above was my "idea" of how it will work, but, of course, this does not happen.
source share