时间:2021-05-28
//基本代码设计
<div id="div-datagrid">
<asp:DataGrid id="DataGrid1" runat="server" CssClass="Grid" UseAccessibleHeader="True">
<AlternatingItemStyle CssClass="GridAltRow"></AlternatingItemStyle>
<ItemStyle CssClass="GridRow"></ItemStyle>
<Columns>
<asp:BoundColumn DataField="Name" HeaderText="Name"
ItemStyle-Wrap="False"></asp:BoundColumn>
<asp:BoundColumn DataField="Address" HeaderText="Address"
ItemStyle-Wrap="False"></asp:BoundColumn>
<asp:BoundColumn DataField="City" HeaderText="City"
ItemStyle-Wrap="False"></asp:BoundColumn>
<asp:BoundColumn DataField="State" HeaderText="State"
ItemStyle-Wrap="False"></asp:BoundColumn>
<asp:BoundColumn DataField="Zip" HeaderText="Zip"
ItemStyle-Wrap="False"></asp:BoundColumn>
<asp:BoundColumn DataField="Random Babble"
HeaderText="Random Babble"
ItemStyle-Wrap="False"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</div>
//可以给一个按钮触发lockCol('');
function lockCol(tblID) {
var table = document.getElementById(tblID);
var button = document.getElementById('toggle');
var cTR = table.getElementsByTagName('tr'); //collection of rows
if (table.rows[0].cells[0].className == '') {
for (i = 0; i < cTR.length; i++)
{
var tr = cTR.item(i);
tr.cells[0].className = 'locked'
}
button.innerText = "Unlock First Column";
} else {
for (i = 0; i < cTR.length; i++)
{
var tr = cTR.item(i);
tr.cells[0].className = ''
}
button.innerText = "Lock First Column";
}
}
//css样式代码
div#div-datagrid {
width: 420px;
height: 200px;
overflow: auto;
scrollbar-base-color:#ffeaff;
}
td.locked, th.locked {
font-size: 14px;
font-weight: bold;
text-align: center;
background-color: navy;
color: white;
border-right: 1px solid silver;
position:relative;
cursor: default;
left: expression(document.getElementById("div-datagrid").scrollLeft-2);
}
th {
font-size: 14px;
font-weight: bold;
text-align: center;
background-color: navy;
color: white;
border-right: 1px solid silver;
position:relative;
cursor: default;
top: expression(document.getElementById("div-datagrid").scrollTop-2);
z-index: 10;
}
th.locked {z-index: 99;}
.GridRow {font-size: 10pt; color: black; font-family: Arial;
background-color:#ffffff; height:35px;}
.GridAltRow {font-size: 10pt; color: black; font-family: Arial;
background-color:#eeeeee; height:35px;}
///指定那些不动!
Sub Item_Bound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) _
Handles DataGrid1.ItemDataBound
e.Item.Cells(0).CssClass = "locked"
//e.Item.Cells(1).CssClass = "locked"
End Sub
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了asp.net中的GridView分页问题。分享给大家供大家参考。具体分析如下:在ASP.NET中,经常会使用到GridView的分页,一般情况下
以下是ASP.NET基本控件的数据绑定:webconfig:1.gridview:SqlConnectionconn=newSqlConnection(Sy
本文实例讲述了asp.net获取ListView与gridview中当前行的行号。分享给大家供大家参考,具体如下:aspx中,在gridview/ListVie
看到一个问题:定时更新GridView的某一列中的状态文本。马上就有了思路:GridView最后会生成表格,所以我们在页面中通过Ajax更新表格的列,从而达到a
gridview是asp.net常用的显示数据控件,对于.net开发人员来说应该是非常的熟悉了。gridview自带有许多功能,包括分页,排序等等,但是作为一个