or

Protected Sub myIssueGrid_ExportCellFormatting(sender As Object, e As ExportCellFormattingEventArgs) Handles myIssueGrid.ExportCellFormatting Dim item As GridDataItem = DirectCast(e.Cell.Parent, GridDataItem) If item.ItemType = GridItemType.AlternatingItem Then item.Style("horizontal-align") = "middle" Else item.Style("horizontal-align") = "middle" End If End Sub If e.CommandName = "ExportToExcel" Then IsExport = True myIssueGrid.Columns(0).Visible = False End If<CommandItemTemplate> <table width="100%"> <tr> <td style="width:50%"><asp:LinkButton ID="lnkTransfer" runat="server" CommandName="Trans" Text="Click to Transfer Items" Font-Underline="true"></asp:LinkButton></td> <td style="width:50%" align="right"><asp:Button ID="btnExport" runat="server" CommandName="ExportToExcel" Text="Export Excel" /></td> </tr> </table> </CommandItemTemplate>void uxDirectoryGrid_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridDataItem) { //set the onError attribute to handle images which do not exist var imageColumnIndex = e.Item.OwnerTableView.Columns.FindByUniqueName("AccountName").OrderIndex; var imageCell = e.Item.Cells[imageColumnIndex]; var image = imageCell.Controls[0] as Image; //<--- BOMBS OUT HERE: Specified argument was out of the range of valid values
if (image != null) { image.Attributes["onError"] = "this.src='EmployeePhotos/404.jpg'"; } }}