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:

  1. <script language="javascript" type="text/javascript">
  2. function PrintDataGrid(elementname) {
  3. var oDiv = document.getElementById(elementname);
  4. var oprint_window = window.open('', '', 'letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
  5.  
  6. oprint_window.document.write(oDiv.innerHTML);
  7. oprint_window.document.close();
  8. oprint_window.focus();
  9. oprint_window.print();
  10. oprint_window.close();
  11. }
  12. </script>
  13.  
  14.  
  15. <div id="DatagridData">
  16. <asp:Datagrid>…</asp:Datagrid>
  17. </div>
  18.  
  19. <asp:Button ID="btnPrint" runat="server" OnClientClick="javascript:PrintDataGrid('DatagridData');" />

or

  1. <input id="Button1" type="button" value="button" onclick="javascript:PrintDataGrid('DatagridData')" />

,

No Comments


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.

, ,

No Comments



SetPageWidth