Archive for the ‘DataGrid’ Category
How to Print Datagrid in ASP.Net
To print the datagrid data alone, you need to encapsulate the datagrid using div element.
Example:
-
<script language="javascript" type="text/javascript">
-
function PrintDataGrid(elementname) {
-
var oDiv = document.getElementById(elementname);
-
var oprint_window = window.open('', '', 'letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
-
-
oprint_window.document.write(oDiv.innerHTML);
-
oprint_window.document.close();
-
oprint_window.focus();
-
oprint_window.print();
-
oprint_window.close();
-
}
-
</script>
-
-
-
<div id="DatagridData">
-
<asp:Datagrid>…</asp:Datagrid>
-
</div>
-
-
<asp:Button ID="btnPrint" runat="server" OnClientClick="javascript:PrintDataGrid('DatagridData');" />
or
-
<input id="Button1" type="button" value="button" onclick="javascript:PrintDataGrid('DatagridData')" />
A Generic error occured in GDI+
Source Control:
If this exception occurred in DataGrid Control, check if the displayed data is large. This might be the caused of the exception.