/// <summary> /// This event fires when the user clicks on save unit report /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void UnitReoprtGV_RowCommand(object sender, GridViewCommandEventArgs e) { string command = e.CommandName; if (command == "SaveUnitReport") { int crewId = int.Parse(e.CommandArgument.ToString()); GridViewRow row = ((e.CommandSource as LinkButton).NamingContainer) as GridViewRow; //Gets hold of the GridViewRow string KS = ((row.FindControl("KM_Start") as TextBox).Text); string KE = ((row.FindControl("KM_End") as TextBox).Text); int KmStart = string.IsNullOrEmpty(KS) ? 0 : int.Parse(KS); int KmEnd = string.IsNullOrEmpty(KE) ? 0 : int.Parse(KE); string comment = (row.FindControl("Comment") as TextBox).Text; string crew = (row.FindControl("Unit") as Label).Text; InfoUserControl.TryRun(() => { CrewController crewManager = new CrewController(); crewManager.UpdateCrew(crewId, KmStart, KmEnd, comment); PopulateUnitReport(); }, crew + " was updated successfully!"); } }