protected void _grdTodaysTimesheet_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.Header) { foreach (TableCell tc in e.Row.Cells) { if (tc.Controls.Count == 1) { if (tc.HasControls()) { // search for the header link LinkButton lnk = (LinkButton)tc.Controls[0]; if (lnk != null) { // inizialize a new image System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image(); // setting the dynamically URL of the image img.ImageUrl = "~/Images/PNGs/sort_az_" + (_grdTodaysTimesheet.SortDirection == SortDirection.Ascending ? "descending" : "ascending") + ".png"; // checking if the header link is the user's choice if (_grdTodaysTimesheet.SortExpression == lnk.CommandArgument) { // adding a space and the image to the header link tc.Controls.Add(new LiteralControl(" ")); tc.Controls.Add(img); } } } } } } if (e.Row.RowType == DataControlRowType.DataRow) { UnPostedTimeSearchItem timeEntry = (UnPostedTimeSearchItem)e.Row.DataItem; LinkButton lnkMatterReference = (LinkButton)e.Row.FindControl("_lnkBtnEditMatter"); lnkMatterReference.Text = lnkMatterReference.Text.Insert(6, "-"); //Truncate large descriptions if (timeEntry.MatterDescription.Length > 20) { Label lbldescription = (Label)e.Row.FindControl("_lblMatterDescription"); lbldescription.Text = timeEntry.MatterDescription.Substring(0, 20) + "..."; } //Truncate large notes if (timeEntry.TimeComments.Length > 20) { Label lblNotes = (Label)e.Row.FindControl("_lblNotes"); lblNotes.Text = timeEntry.TimeComments.Substring(0, 20) + "..."; } //Add to the total cost (displayed in the footer) _charge += timeEntry.TimeCharge; Label lblUnits = (Label)e.Row.FindControl("_lblUnits"); lblUnits.Text = (timeEntry.TimeElapsed / _logonSettings.TimeUnits).ToString(); Label lblTime = (Label)e.Row.FindControl("_lblTime"); lblTime.Text = AppFunctions.ConvertUnits(timeEntry.TimeElapsed); } else if (e.Row.RowType == DataControlRowType.Footer) { ((Label)e.Row.FindControl("_lblTotal")).Text = "£" + _charge.ToString("0.00"); } } catch (System.ServiceModel.EndpointNotFoundException) { _lblMessage.Text = DataConstants.WSEndPointErrorMessage; _lblMessage.CssClass = "errorMessage"; } catch (Exception ex) { _lblMessage.CssClass = "errorMessage"; _lblMessage.Text = ex.Message; } }