I have a Gridview and a Title that I want to print on a page. However, there is one cell in the template field that I do not want to include when printing. How can I exclude just that cell? Here is the code snippet:
<div id="Printmeonly" align="center">
<table width="100%">
<tr id="trtitle" style="display:none">
<td style="color:Blue;font-size:large" align="center" colspan="2"><strong>Incident # <%=Request.QueryString["Inc"].ToString() %> Notes (Store <%=Request.QueryString["Loc"].ToString() %>)</strong><br /><br /></td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px"
CellPadding="3"
DataSourceID="SqlDataSource" ShowFooter="True">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<Columns>
<asp:BoundField DataField="Somefield" HeaderText="Somefield"
SortExpression="Somefield" Visible="False" />
<asp:TemplateField ShowHeader="True" HeaderText="Action" ItemStyle-CssClass="dontPrint" ControlStyle-CssClass="dontPrint" HeaderStyle-CssClass="dontPrint" FooterStyle-CssClass="dontPrint">
<ItemTemplate>
<asp:ImageButton ID="bttneditNote" ImageUrl="~/images/bttnEdit.gif" style="cursor:pointer" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit"></asp:ImageButton>
<asp:ImageButton ID="bttndeleteNote" ImageUrl="~/images/bttnDelete.gif" OnClientClick="if(confirm('Are you sure you want to delete this Application?')==false) return false;" style="cursor:pointer" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete"></asp:ImageButton>
</ItemTemplate>
<EditItemTemplate>
<asp:ImageButton ID="bttnEditNote" ImageUrl="~/images/bttnSave.gif" style="cursor:pointer" runat="server" CausesValidation="False"
CommandName="Update" Text="Update"></asp:ImageButton>
<asp:ImageButton ID="bttnCancelNote" ImageUrl="~/images/bttnCancel.gif" style="cursor:pointer" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel"></asp:ImageButton>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#DCDCDC" />
</asp:GridView>
</td>
</tr>
</table>
</div>
<table>
<tr>
<td align="center" colspan="2"><br />
<asp:ImageButton ID="bttnprint" runat="server" OnClientClick="CallPrint('Printmeonly');" ImageUrl="~/somefolder/images/PrintButton.gif" style="cursor:pointer" />
</td>
</tr>
<script type="text/javascript'>
function CallPrint(strid) {
var trtitle = document.getElementById('trtitle');
trtitle.style.display = '';
var prtContent = document.getElementById(strid);
var WinPrint = window.open('', '', 'left=0,top=0,width=1,height=1,toolbar=1,scrollbars=1,status=1');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
</script>
When I print, I use a Javascript function to specify which div tag id to print. Any ideas on how to remove the specific field from printing?
Edit: I made changes to the markup. The template field with buttons is the one I need to hide.