Hi,
It's almost working but my application crashes because of ONLY ONE LINE which I don't really understand. Could you please look at the code bellow and tell me if you can why it's saying "Object reference not set to an instante of an object"
specially when the code is not going anywhere else after that.
Based on this code, I'm adding a new row, which works. Now if the user doesn't enter all I want, I cancel everything and I remove
the new added object from the collection and I'm trying to refresh the grid. The line that crashes is the Rebind() in the RowEditended
It's almost working but my application crashes because of ONLY ONE LINE which I don't really understand. Could you please look at the code bellow and tell me if you can why it's saying "Object reference not set to an instante of an object"
specially when the code is not going anywhere else after that.
Based on this code, I'm adding a new row, which works. Now if the user doesn't enter all I want, I cancel everything and I remove
the new added object from the collection and I'm trying to refresh the grid. The line that crashes is the Rebind() in the RowEditended
private void rgvTimes_AddingNewDataItem(object sender, GridViewAddingNewEventArgs e) |
{ |
if (!_AddingNewTimeRow) |
{ |
_AddingNewTimeRow = true; |
_AddedTime = new Object_Time() { JobId = SelectedJob.JobId }; |
_Times.Add(_AddedTime); |
rgvTimes.Rebind(); |
//This is something I'm trying to make the little black triangle marquee selector on the row // and trying to make my columns in editing mode. But doesn't even seem to work and it's not my bigest problem. rgvTimes.SelectedItem = _AddedTime; |
rgvTimes.CurrentItem = rgvTimes.Columns[2]; |
rgvTimes.BeginEdit(); |
} |
else |
_SAPMessage.Show("Vous devez saisir les information de la nouvelle ligne avant d'en ajouter une autre...", "Message..."); |
} |
private void rgvTimes_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e) |
{ |
try |
{ |
if (_AddingNewTimeRow) |
{ |
Object_Time Time = e.Row.DataContext as Object_Time; |
if (Time.EmployeName == null || Time.PosteName == null) |
{ |
rgvTimes.CancelEdit(); |
_Times.Remove(Time); |
rgvTimes.Rebind(); // If I remove this line everything works fine except the grid isn't refreshed... |
} |
else |
_Proxy.AddNewTimeAsync(Gear.ServiceKey(), Time); |
} |
_AddingNewTimeRow = false; |
} |
catch (Exception ex) |
{ |
_SAPMessage.Show(ex.Message, "Error..."); |
} |
} // When the application go out of this event, it crashes with "Object reference not set to an isntance of an object" |