会员
周边
新闻
博问
闪存
赞助商
YouClaw
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
着迷Linux
菲一打
当鼠标移动时,可改变DataGrid条目背景色的代码
<
%@ Page Language
=
"
VB
"
AutoEventWireup
=
"
True
"
Debug
=
"
true
"
%
>
<
%@ Import
Namespace =
Namespace
=
"
System.Data
"
%
>
<
%@ Import
Namespace =
Namespace
=
"
System.Data.OleDb
"
%
>
<
script runat
=
"
server
"
>
dim
MyConnection
as
OleDbConnection
Sub Page_Load()
Sub
Page_Load(sender
As
Object
, e
As
EventArgs)
MyConnection
=
New
OleDbConnection(
"
Provider=Microsoft.Jet.OLEDB.4.0; Data Source =
"
+
Server.MapPath(
"
.
"
)
+
"
/db/data.mdb
"
)
If
Not
IsPostBack
Then
BindGrid()
End
If
End Sub
Sub MyDataGrid_Page()
Sub
MyDataGrid_Page(sender
as
Object
, e
As
DataGridPageChangedEventArgs)
MyDataGrid.CurrentPageIndex
=
e.NewPageIndex
BindGrid()
End Sub
Sub BindGrid()
Sub
BindGrid()
Dim
MyCommand
As
OleDbDataAdapter
=
new
OleDbDataAdapter(
"
select * from [min]
"
, MyConnection)
Dim
DS
As
DataSet
=
new
DataSet()
MyCommand.Fill(DS,
"
min
"
)
MyDataGrid.DataSource
=
DS.Tables(
"
min
"
).DefaultView
MyDataGrid.DataBind()
End Sub
</
script
>
<
script language
=
"
javascript
"
>
startHighlight
=
Function (()
function
()
{
if
(document.all
&&
document.getElementById)
{
navRoot
=
document.getElementById(
"
MyDataGrid
"
);
//
Get
a reference
to
the TBODY element
tbody
=
navRoot.childNodes[
0
];
for
(i
=
1
; i
<
tbody.childNodes.length
-
1
; i
++
)
{
node
=
tbody.childNodes[i];
if
(node.nodeName
==
"
TR
"
)
{
node.onmouseover
=
Function (()
function
()
{
this.className
=
"
over
"
;
}
node.onmouseout
=
Function (()
function
()
{
this.className
=
this.className.
replace
(
"
over
"
,
""
);
}
}
}
}
}
window.onload
=
startHighlight;
</
script
>
<
style
>
tr:hover, tr.over td { background
-
color: #ffcc00;
</
style
>
<
Body
>
<
form runat
=
"
server
"
>
<
asp:DataGrid id
=
"
MyDataGrid
"
AllowPaging
=
"
True
"
PageSize
=
"
5
"
OnPageIndexChanged
=
"
MyDataGrid_Page
"
runat
=
"
server"
AutoGenerateColumns
=
"
False"
Width
=
"
200
"
>
<
HeaderStyle BackColor
=
"
Navy
"
ForeColor
=
"
White
"
Font
-
Bold
=
"
True
"
HorizontalAlign
=
"
Center
"
/>
<
PagerStyle Mode
=
"
NextPrev"
HorizontalAlign
=
"
Right
"
NextPageText
=
"
Next"
PrevPageText
=
"
Prev
"
/>
<
HeaderStyle BackColor
=
"
#336699
"
ForeColor
=
"
#ffffff
"
Font
-
Bold
=
"
true
"
/>
<
AlternatingItemStyle BackColor
=
"
#eeeeee
"
/>
<
Columns
>
<
asp:BoundColumn DataField
=
"
id
"
HeaderText
=
"
ID
"
/>
<
asp:TemplateColumn HeaderText
=
"
zhuti
"
>
<
ItemTemplate
>
<
asp:Label ID
=
"
lblTotalPrice
"
Text
=
'
<%#(Container.DataItem("zhuti"))%>' Runat=server />
</
ItemTemplate
>
</
asp:TemplateColumn
>
</
Columns
>
</
asp:DataGrid
>
</
form
>
</
Body
>
发表于
2005-03-09 11:26
菲一打
阅读(
232
) 评论(
0
)
收藏
举报
刷新页面
返回顶部
公告
导航
博客园
首页
新随笔
新文章
联系
订阅
管理