有用於填充數據的網格,頭位置不固定的,而印刷,
<asp:Panel ID="Panel1" runat="server" ScrollBars="Auto" Width="1000px"
Height="8000px" BorderColor="Black" BorderWidth="1px" Visible="true" BackColor="LightGray">
<asp:GridView ID="List" runat="server" Visible="False" OnRowDataBound="List_RowDataBound" AutoGenerateColumns="true">
<HeaderStyle CssClass="gridstyleHead" />
<RowStyle CssClass="gridRowstyle" />
</asp:GridView>
並且存在適用於網格
.gridstyleHead {
white-space: nowrap;
text-align: left;
font-family: Arial;
font-size: 10pt;
font-weight: lighter;
padding-left: 3px;
position: relative;
top: expression(this.offsetParent.scrollTop);
z-index: 10;
}
.gridRowstyle {
white-space: nowrap;
border-width: 1px;
background-color: white;
font-family: Arial;
font-size: 9pt;
height: 29px;
}
的樣式表我正嘗試打印網格中的數據
function btnPrint_Click() {
varfoo="toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,
width=500,height=600,left=50,top=25";
varprintdata=document.getElementById('<%=Panel1.ClientID%>').innerHTML;
var printWindow = window.open('', 'PRINT', foo);
var radioButtons = document.getElementsByName("ordrcvd");
var ord = '';
for (var x = 0; x < radioButtons.length; x++) {
if (radioButtons[x].checked) {
ord = radioButtons[x].value;
}
}
printWindow.document.write('<html><head><link rel="stylesheet" href="css/invoice.css" />');
printWindow.document.write(' </head><body>');
printWindow.document.write('<table>');
printWindow.document.write('<tr><td style = "font-weight:bold;font-family:arial;font-size:12"> order Received' + ' : ');
printWindow.document.write('</td><td style = "font-weight:normal;font-family:arial;font-size:12">');
printWindow.document.write(document.getElementById('<%= txtordRcvd.ClientID%>').value);
printWindow.document.write('</td></tr>');
printWindow.document.write('<tr><td> </br>');
printWindow.document.write('</td></tr>');
printWindow.document.write(' </table>');
printWindow.document.write(printContent);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.focus();
return false;
}
但問題是網格中的標題不是固定的,並且 我正在打印的網頁顯示的標題不是固定的。
網格中的標題不是固定的,但是當我試圖打印該網格並向下滾動時,標題位置錯位。
任何人都可以提出如何應用樣式表是我打印網格,使頭將被固定在事先
感謝,