gridview 雙擊單擊事件
<script language="javascript">
function DbClickEvent(d)
{
window.alert("事件類型: DoubleClidk 作用對象: " + d);
}
function ClickEvent(d)
{
window.alert("事件類型: OnClick 作用對象: " + d);
}
function GridViewItemKeyDownEvent(d)
{
window.alert("事件類型: GridViewItemKeyDownEvent 作用對象: " + d);
}
function KeyDownEvent()
{
if( event.altKey && event.keyCode > 48 && event.keyCode < 54 )
{
window.alert("事件類型: FormKeyDownEvent 選中記錄數: " + ( parseInt(event.keyCode) - 48 ));
}
}
</script>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if( e.Row.RowType == DataControlRowType.DataRow)
{
//鼠標移動到每項時顏色交替效果
//鼠標移動到每項時顏色交替效果
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#E2F2FF'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
//單擊/雙擊 事件
e.Row.Attributes.Add("OnDblClick", "DbClickEvent('" + e.Row.Cells[1].Text + "')");
e.Row.Attributes.Add("OnClick", "ClickEvent('" + e.Row.Cells[1].Text + "')");
e.Row.Attributes.Add("OnKeyDown", "GridViewItemKeyDownEvent('" + e.Row.Cells[1].Text + "')");
//設置懸浮鼠標指針形狀爲"小手"
e.Row.Attributes["style"] = "Cursor:hand";
}
}
源於網絡...
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.