您的位置:首页 > 其它

DATAGRID固定表头【转】

2015-07-15 14:03 232 查看
<%@ Page Inherits="www.MyCodeBehind" Src="result.cs" %>

<html>

<head>

<title>查找日工作報告&計劃</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<style type="text/css">

div#tbl-container {

width: 780px;

height: 290px;

overflow: auto;

scrollbar-base-color:#ffeaff;

}

table {

table-layout: fixed;

border-collapse: collapse;

background-color: "#718BD6";

}

div#tbl-container table th {

width: 100px;

}

thead th, thead th.locked {

font-size: 12px;

font-weight: bold;

text-align: left;

background-color: navy;

color: white;

border-right: 0px solid silver;

position:relative;

cursor: default;

}

thead th {

top: expression(document.getElementById("tbl-container").scrollTop-2); /* IE5+ only */

z-index: 20;

}

</style>

<script language="javascript">

function openwin() {

  window.open ("add.aspx", "newwindow", "height=350, top=230 , left=500 , width=300, toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no") //写成一行

  }

function newwin(htmlurl){

var stock = window.open(htmlurl,"temp","top=200,left=260,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=720,height=400")

stock.focus()

}

function newwin2(htmlurl){

var stock = window.open(htmlurl,"temp","top=200,left=100,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=780,height=400")

stock.focus()

}

</script>

<script>

function del(repday_id)

{

if(confirm("您确实要删除这張日工作報告&計劃吗?"))

{

document.location.href="delete.aspx?repday_id=" + repday_id;

}

}

</script>

<link rel="stylesheet" href="Style.css" type="text/css">

<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>

<form runat="server">

<div id="tbl-container">

<table id="tbl" border=1>

<thead>

<tr>

<th>項次</th>

<th>查看詳情</th>

<th>報告人</th>

<th>部門</th>

<th>日工作報告</th>

<th>日工作計劃</th>

<th>填寫時間</th>

<th>最後修改時間</th>

<th>修改</th>

<th>删除</th>

</tr>

</thead>

<tbody>

<tr>

<td colspan=10>

<ASP:DataGrid id="MyList"

OnSortCommand="MyList_SortCommand"

showheader=false

AllowPaging="True"

AllowSorting="true"

PageSize="20"

ShowFooter="false"

OnPageIndexChanged="MyList_Page"

PagerStyle-Visible="false"

runat="server"

Width="100%"

GridLines="None"

CellPadding="1"

CellSpacing="1"

bgcolor="#66CCCC"

HeaderStyle-BackColor="#718BD6"

HeaderStyle-ForeColor="#FFFF66"

AlternatingItemStyle-BackColor="#ffffff"

itemstyle-backcolor="#ffffff"

Font-Name="宋体"

Font-Size="8pt"

EnableViewState="false"

AutoGenerateColumns="false"

DataKeyField="repday_id">

<Columns>

<asp:TemplateColumn HeaderText="項次">

<ItemTemplate>

<%# Container.ItemIndex+1+this.MyList.CurrentPageIndex*this.MyList.PageSize%>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="查看詳情">

<ItemTemplate>

<asp:HyperLink Text='查看日工作報告&計劃' imageurl="images/file.gif" NavigateUrl='<%# "javascript:newwin(\"look.aspx?repday_id="+DataBinder.Eval(Container.DataItem,"repday_id").ToString()+"\");" %>' runat="server"/>

</ItemTemplate>

</asp:TemplateColumn>

<asp:BoundColumn HeaderText="報告人" DataField="repday_name" />

<asp:BoundColumn ItemStyle-Width="100px" HeaderText="部門" DataField="departmentname" />

<asp:TemplateColumn HeaderText="日工作報告">

<ItemTemplate>

<%# SubStr(DataBinder.Eval(Container.DataItem,"repday_body").ToString())%>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="日工作計劃">

<ItemTemplate>

<%# SubStr(DataBinder.Eval(Container.DataItem,"proday_body").ToString())%>

</ItemTemplate>

</asp:TemplateColumn>

<asp:BoundColumn SortExpression="repday_indate" HeaderText="填寫時間" DataFormatString="{0:yyyy-MM-dd HH:mm}" DataField="repday_indate" />

<asp:BoundColumn SortExpression="repday_editdate" HeaderText="最後修改時間" DataFormatString="{0:yyyy-MM-dd HH:mm}" DataField="repday_editdate" />

<asp:TemplateColumn HeaderText="修改">

<ItemTemplate>

<asp:HyperLink Text='修改' Enabled='<%#(Convert.ToString(DataBinder.Eval(Container.DataItem,"repday_name")).Trim()==Session["name"].ToString())%>' NavigateUrl='<%# "javascript:newwin2(\"edit.aspx?repday_id="+DataBinder.Eval(Container.DataItem,"repday_id").ToString()+"\");"
%>' runat="server"/>

</ItemTemplate>

</asp:TemplateColumn>

<asp:HyperLinkColumn Text="删除" HeaderText="删除" DataNavigateUrlField="repday_id" DataNavigateUrlFormatString="javascript:del({0})"></asp:HyperLinkColumn>

</Columns>

</asp:DataGrid>

</td>

</tr></tbody></table></div>

<table width="100%" border="0" align="center" bgcolor="#718BD6">

<tr>

<td width="40" height="21">

<asp:LinkButton id="btnFirst" runat="server"

Text="首 頁"

CommandName="Pager"

CommandArgument="First"

ForeColor="navy"

Font-Name="verdana" Font-size="8pt"

OnCommand="PagerButtonClick" />

</td>

<td width="53" height="11">

<asp:LinkButton id="btnPrev" runat="server"

Text="上一頁"

CommandName="Pager"

CommandArgument="Prev"

ForeColor="navy"

Font-Name="verdana" Font-size="8pt"

OnCommand="PagerButtonClick" />

</td>

<td width="53" height="11">

<asp:LinkButton id="btnNext" runat="server"

Text="下一頁"

CommandName="Pager"

CommandArgument="Next"

ForeColor="navy"

Font-Name="verdana" Font-size="8pt"

OnCommand="PagerButtonClick" />

</td>

<td width="53" height="11">

<asp:LinkButton id="btnLast" runat="server"

Text="尾 頁"

CommandName="Pager"

CommandArgument="Last"

ForeColor="navy"

Font-Name="verdana" Font-size="8pt"

OnCommand="PagerButtonClick" />

</td>

<td width="64" height="11">

<font color="#0000A0">頁 </font><font color="#FF0000"><asp:Label id="lblCurrentPage" runat="server"/>

</font> / <font color="#FF0000"><asp:Label id="lblPageCount" runat="server"/>

</font>

</td>

<td width="73" height="11">

<font color="#0000A0">共<font color="#FF0000"><asp:Label id="lblRecordCount" runat="server"/>

</font> 條</font>

</td>

<td width="90" height="11">

<font color="#FF0000">20</font><font color="#0000A0">條記錄/頁</font>

</td>

<td width="110" height="11">

<font color="#0000A0">轉到第 <asp:TextBox class="input" id="txtIndex" runat="server" Width="20" height="15" Columns="2" Font-Size="11px" ForeColor="#0000A0" OnTextChanged="txtIndex_Changed"/>

頁</font>

</td>

</tr>

</table>

</form>

</body>

</html>

收藏于 2010-12-06

来自于百度空间
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: