asp.net gridview指定某一列滾動(dòng)
<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>
//可以給一個(gè)按鈕觸發(fā)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 container to wrap the datagrid */
div#div-datagrid {
width: 420px;
height: 200px;
overflow: auto;
scrollbar-base-color:#ffeaff;
}
/* Locks the left column */
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;
/*IE5+ only*/
left: expression(document.getElementById("div-datagrid").scrollLeft-2);
}
/* Locks table header 這里是表頭不動(dòng),要表頭動(dòng)那就把這一段注釋!*/
th {
font-size: 14px;
font-weight: bold;
text-align: center;
background-color: navy;
color: white;
border-right: 1px solid silver;
position:relative;
cursor: default;
/*IE5+ only*/
top: expression(document.getElementById("div-datagrid").scrollTop-2);
z-index: 10;
}
/* Keeps the header as the top most item. Important for top left item*/
th.locked {z-index: 99;}
/* DataGrid Item and AlternatingItem Style*/
.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;}
///指定那些不動(dòng)!
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
相關(guān)文章
GridView自動(dòng)增加序號(hào)(三種實(shí)現(xiàn)方式)
第一種方式,直接在Aspx頁(yè)面GridView模板列中.這種的缺點(diǎn)是到第二頁(yè)分頁(yè)時(shí)又重新開(kāi)始了,第二種方式分頁(yè)時(shí)進(jìn)行了計(jì)算,這樣會(huì)累計(jì)向下加,點(diǎn)三種放在cs代碼中2013-04-04讓VS2008對(duì)JQuery語(yǔ)法的智能感知更完美一點(diǎn)
上周Rich Strahl的POST中提到一個(gè)新發(fā)布的VS2008 hotfix修復(fù)了VS2008對(duì)Javascript智能感知的一些BUG,fixed之后可以讓VS2008對(duì)JQuery提供智能感知,讓我等JQuery fans欣喜了一陣子。可仔細(xì)一看,還需要另外給JQuery添加上XML comments才行 :( 喪氣了...2008-03-03ASP.NET?Core使用MiniProfiler分析應(yīng)用
這篇文章介紹了ASP.NET?Core使用MiniProfiler分析應(yīng)用的方法,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-02-02ASP.NET Core擴(kuò)展庫(kù)之實(shí)體映射使用詳解
這篇文章主要介紹了ASP.NET Core擴(kuò)展庫(kù)之實(shí)體映射使用詳解,幫助大家更好的理解和學(xué)習(xí)使用.net技術(shù),感興趣的朋友可以了解下2021-03-03ASP.NET實(shí)現(xiàn)用圖片進(jìn)度條顯示投票結(jié)果
ASP.NET實(shí)現(xiàn)用圖片進(jìn)度條顯示投票結(jié)果...2007-06-06Asp.net6.0?Swagger使用問(wèn)題及解決過(guò)程
這篇文章主要介紹了Asp.net6.0?Swagger使用備忘,文中介紹了在Docker中顯示OpenApiInfo的中文內(nèi)容,顯示xml注釋及如何顯示Header的問(wèn)題,需要的朋友可以參考下2022-05-05AntDesign Pro + .NET Core 實(shí)現(xiàn)基于JWT的登錄認(rèn)證功能
這篇文章主要介紹了AntDesign Pro + .NET Core 實(shí)現(xiàn)基于JWT的登錄認(rèn)證功能,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-03-03Asp.net Socket客戶端(遠(yuǎn)程發(fā)送和接收數(shù)據(jù))
通過(guò)Socket遠(yuǎn)程發(fā)送與接收數(shù)據(jù)的代碼類2008-11-11ASP.NET筆記之 ListView 與 DropDownList的使用
本篇文章小編為大家介紹,ASP.NET筆記之 ListView 與 DropDownList的使用。需要的朋友參考下2013-04-04