Data Controls :: Printing Gridview Header In Each Printed Page
Dec 3, 2012
How to print the GridView headings in each page, in case the gridview returns about 100 records and we wish to print all of those, with page heading in each page.
I have a gridview that i want to print its header on every page and i want to print a page header on every page. The problem is that one or the other works for me. I can't get both to work at the same time. Below is sample code to show what i've done.
Public Shared Sub PrintWebControl(ByVal ctrl As Control, ByVal Script As String) 'dim StringBuilder sb = new StringBuilder() Dim sb As StringBuilder = New StringBuilder() Dim stringWrite As IO.StringWriter = New IO.StringWriter(sb) Dim htmlWrite As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(stringWrite) If TypeOf ctrl Is WebControl Then Dim w As Unit = New Unit(100, UnitType.Percentage) CType(ctrl, WebControl).Width = w End If Dim pg As Page = New Page() pg.EnableEventValidation = False pg.EnableViewState = False pg.MaintainScrollPositionOnPostBack = False If Script <> String.Empty Then pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script) End If Dim frm As HtmlForm = New HtmlForm() pg.Controls.Add(frm) frm.Attributes.Add("runat", "server") frm.Controls.Add(ctrl) pg.DesignerInitialize() pg.RenderControl(htmlWrite) Dim strHTML As String = stringWrite.ToString() HttpContext.Current.Response.Clear() HttpContext.Current.Response.Write(strHTML) HttpContext.Current.Response.Write("<script>window.print();</script>") HttpContext.Current.Response.End() End Sub
I get the error at line: pg.RenderControl(htmlWrite);
I tried setting the Enable Event Validation to false on the page but that didnt work..
I have an aspx page that I populate to create a diploma. I thn have code that does a "window.print." Unfortunately, the diploma prints with the name of the page and "Page 1 of 1" at the top and the address of the page and the date printed at the bottom. These ruin the diploma. How can I print this page programmatically WITHOUT the header and footer info?
Here is the code I use to populate the diploma page and print it:
using above code i am able to print gridview directly without hidden fields.after added to hiddenfields to gridview , hiddenfield values are visible for printing.after i am using gridview.colums[i].visible=false column not visible while printingproblem is after print the gridview not visible whatever my columns set visible false.Example:at printing time i am set checkbox visible false, after printing i want reload same page with checkbox but check box not visible after printing gridview
Scenario: I have a Gridview where I want to handle the Sorting in a custom control that I've added to the header. I've added this control to my GridView's Header via OnRowCreate event handling. I want the Sort Expressions to persist session to session (via Webparts Personalization)
Here is what I have for adding the custom header control to the GridView Header
[Code]....
This works out well for adding the control, but I can't get anything to persist because these controls are creating initially via postback (per the event) and re-created on all subsequent postbacks. I can't add an If(!IsPostback) because the controls are initially created on the gridview's postback (well at least thats how it's acting when I put it in there) If I were to add this control via the ASP page, not via the Codebehind, I would be able to persist the control. If I try to treat it as though everything is setup correctly, and assign my custom control's controls to [Personalizable], I get a runtime error telling me that I can only have webpartzones in or before Page_init (I'm guessing this is due to when/where the gridview hits the OnRowCreate event). If there is some fundimental logic I'm missing, or best practices that I'm moving away from,
I have gridview with div tag, i have put div tag becouse when user scroll in grid i dont want move grid header section. Its remaining ther and only move data section. Its working fine.
But my datagrid has facility to master details hiearchy of data, When user click one of button its expand details record of that particular parent item.
When user click expand button my gridview header section jump to top of page. How can i stop it
I have a GridView (inside an update panel) that has header text that changes based on some user profile information. I set the header text in the Page_Load function of the page - that works fine. The problem is that when I change to the page number of the GridView, the header text is not redrawn. I am handling the OnPageChanging event to try to update the header text but nothing is happening. I've attached the relevant code.
Did you have any issue to show background images in a gridview with IIS 7. I've exactly applied this [URL] and I've no idea why, my css works for the header but not for:
The alternative row has no background image and the pager too but it works for the header. But when I browse the website online from my laptop, without IIS it works fine. When I check web developer tools from i.e., I've the backround image written in the css so it should come up.
after a webform displays there's a print button where the prinout comes when clicked on it.but the header appears on the first page only.how to make the header to come on all the pages.
i have a gridview bound to sql datasource with template fields binding the columns. I have set the Header Style to a css class. I have 3 columns not bound to data as Add, Edit and Delete. When I set the text color to white for the header only the non bound columns go white. The bound columns are BLUE like hyperlink. Any one know a way round this. (If I set the style in the gridview the all columns are white. Want to set in external css file).