Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
I have posted this question in a few other forums and have not gotten any replies.

I have also tried searching online for an answer and have not been able to find one. Basically, I have a webpage where I display some account information in a gridview. The end user can sort the data by the various header fields and I have a button where they can print out all of the data. Initially, I had paging enabled but was asked to remove it and add a scrollbar instead.

So I created a table that contained the table header information and placed it on top of the gridview and added the gridview inside of a div and set the overflow to get the scrollbar. I am running into problems when the end user clicks on the print button.

When the overflow is set to be visible, the footer is displayed on top of the gridview contents. I did not have this problem when I was enabling and disabling the paging on the gridview.

I have a master page where the footer is defined. When the end user clicks on the print button, the page is displayed with the overflow, the print popup is displayed, and then the page is reset back to not displaying the overflow in the div.

I have a separate stylesheet that I am using for the printing. Is there someway that I can fix this problem? I have tried setting the z-index and that did not work. I also tried dynamically calculating the height based on how many entries in the gridview and that didn't seem to work either. I have been looking at this for a while and am stuck. This is my first asp.net project.

I have included some code snippets below. Thanks in advance for your help!
Code in StyleSheet:
CSS
#footer  
{ 
  position: absolute; 
  bottom: 0; 
  width:100%; 
  height: 50px; 
  background-color: #4E7DD1; 
  clear: both; 
  text-align: center; 
  color: #B6CEF9; 
  font-family: verdana, arial, sans-serif; 
  font-size: 11px; 
  line-height: 18px; 
} 

CSS on div for gridview:
xmk
<div id="ListAllAccountsResultsDiv" style="min-height:300px;max-height:300px;width:1015px;overflow:auto;text-align:left;z-index:2"  runat="server">


Code in Page_Load:
C#
if (IsPostBack) 
{ 
     object ctl = this.FindControl(this.Request.Params.Get("__EVENTTARGET")); 
     if (ctl.GetType().ToString() == "System.Web.UI.WebControls.LinkButton") 
     { 
            System.Web.UI.WebControls.LinkButton lb = (System.Web.UI.WebControls.LinkButton)ctl; 
            System.Web.UI.Control divResults = Page.FindControl("ListAllAccountsResultsDiv"); 
                                                 
             if (lb.ID == this.listAllAcctsBtnPrinterFriendlyFormat.ID) 
             { 
                  if(ListAllAccountsResultsDiv.Style["overflow"].Equals("auto"))
                  { 
                       ListAllAccountsResultsDiv.Style.Remove("overflow"); 
                       ListAllAccountsResultsDiv.Style.Add("overflow", "visible"); 
                       ListAllAccountsButtons.Style.Add("display", "none"); 
                       String cstext = "window.print();setTimeout(\"__doPostBack('" + this.listAllAcctsBtnPrinterFriendlyFormat.UniqueID + "','')\",1000);"; 
                       ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "PopupScript", cstext, true); 
                  }                             
                  else 
                  {                                 
                       ListAllAccountsResultsDiv.Style.Remove("overflow"); 
                       ListAllAccountsResultsDiv.Style.Add("overflow", "auto"); 
                       ListAllAccountsButtons.Style.Remove("display");                         
                   } 
              } 
        } 
 }
Posted
Updated 29-Mar-11 0:04am
v3
Comments
Slacker007 29-Mar-11 6:06am    
Hi Kimberly: If you posted this question in multiple forums here at CP than this is cross-posting and "some" may view poorly on it (just for future reference). I know it is frustrating when you don't get a question answered. :)
KimberlyKetchum 29-Mar-11 9:00am    
Thanks for the reply! Actually, I posted this in some other forums outside of CP. Is there some way to move my question over to the other message boards instead of reposting it? This is the first time that I have used this site and just naturally posted in the Quick Question area before I saw the actual forums listed further down in the drop down list.
Slacker007 29-Mar-11 9:36am    
Since you posted this question in another forum outside of CP then you didn't cross-post. I don't think there is a way to import/export to/from other sites.

You posted your question in the right place. Quick Questions is a good place just as the other forums we have here. By the way, welcome to Code Project.

1 solution

Have you tried removing the max-height:300px style from the ListAllAccountsResultsDiv?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900