DataGrid1_ItemDataBound事件中if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onclickmouse","this.style.backgroundColor='#FFFFCC'");
}
{
e.Item.Attributes.Add("onclickmouse","this.style.backgroundColor='#FFFFCC'");
}
是
e.Item.Attributes.Add("onclick","this.style.backgroundColor='#FFFFCC'");
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Organise_List</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK href="../Css/Public.css" type="text/css" rel="stylesheet">
<script language="javascript" src="../Js/CoolButton.js"></script>
<script language="javascript">
var LastBgColor = null;
var LastObj = null;
var DeptId = null;
var PositionId = null;
// 选择
function SelectSet(e, ThisDeptId, ThisPositionId)
{
qx();
if(LastObj != null)
{
LastObj.style.backgroundColor = LastBgColor;
LastObj.style.color = '#000000'
}
LastObj = e.offsetParent.parentNode;
LastBgColor = LastObj.style.backgroundColor;
LastObj.style.backgroundColor = '#DEFFDE';
LastObj.style.color = '#FF0000'
DeptId = ThisDeptId;
PositionId = ThisPositionId;
document.all.sc.disabled = false;
document.all.xg.disabled = false;
if(ThisPositionId == "")
{
document.all.yd.disabled = false;
}
document.all.qx.disabled = false;
}
// 取消
function qx()
{
document.all.sc.disabled = true;
document.all.xg.disabled = true;
document.all.yd.disabled = true;
document.all.qx.disabled = true;
try{
LastObj.style.backgroundColor = LastBgColor;
LastObj.style.color = '#000000'
}catch(e){};
DeptId = null
PositionId = null;
LastObj = null;
LastBgColor = null;
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="Organise_List.aspx?DeptId=89" id="Form1">
<input type="hidden" name="__VIEWSTATE" value="dDwxMjM3MzkzOTQ4Ozs+nLbJV/v07qond1kaCA7ASk5Acq0=" /> <table width="1" border="0" cellspacing="0" cellpadding="5">
<tr>
<td id="xjbm" height="22" class="coolButton" align="center" onclick="AddDept()" width="70">
<nobr style="POSITION:relative;TOP:1px"> 新建部门 </nobr>
</td> <td id="xjgw" width="70" class="coolButton" align="center" onclick="AddPosition()">
<nobr style="POSITION:relative;TOP:1px"> 新建岗位 </nobr>
</td> <td width="70" class="coolButton" align="center" onclick="parent.location.href(parent.location.href)">
<nobr style="POSITION:relative;TOP:1px"> 刷新 </nobr>
</td>
<td id="sc" width="70" class="coolButton" align="center" onclick="ThisDel()" disabled="disabled">
<nobr style="POSITION:relative;TOP:1px"> 删除 </nobr>
</td> <td id="xg" width="70" class="coolButton" align="center" onclick="ThisEdit()" disabled="disabled">
<nobr style="POSITION:relative;TOP:1px"> 修改 </nobr>
</td> <td id="yd" width="70" class="coolButton" align="center" disabled="disabled" onclick="ThisMove()">
<nobr style="POSITION:relative;TOP:1px"> 移动 </nobr>
</td> <td id="qx" width="70" class="coolButton" align="center" onclick="qx()" disabled="disabled">
<nobr style="POSITION:relative;TOP:1px"> 取消 </nobr>
</td> </tr>
</table>
<br>
<table cellspacing="0" cellpadding="5" rules="all" width="100%" bordercolor="#bdbabd" border="1" id="thisDataGrid" style="border-color:#bdbabd;border-width:1px;border-style:solid;font-size:9pt;border-collapse:collapse;background-image: url('../Images/007.gif')">
<tr align="Center" style="color:#000000;height:25px;">
<td>岗位名称</td><td>类型</td><td>岗位描述</td><td style="width:50px;">
操作
</td>
</tr><tr style="color:#000000;background-color:#FFFFFF;height:25px;">
<td>财务部</td><td>部门</td><td>公司的财务管理</td><td>
<div align="center" style="height:22px" class="coolButton" onclick="SelectSet(this,'17','')">
<nobr style="POSITION:relative;TOP:3px"> 操作 </nobr>
</div>
</td>
</tr><tr style="color:#000000;background-color:#f7f3ef;height:25px;">
<td>顾委会</td><td>部门</td><td>公司的公共关系和投资决策顾问</td><td>
<div align="center" style="height:22px" class="coolButton" onclick="SelectSet(this,'53','')">
<nobr style="POSITION:relative;TOP:3px"> 操作 </nobr>
</div>
</td>
</tr><tr style="color:#000000;background-color:#FFFFFF;height:25px;">
<td>管理软件事业部</td><td>部门</td><td>神经网络管理信息系统</td><td>
<div align="center" style="height:22px" class="coolButton" onclick="SelectSet(this,'4589','')">
<nobr style="POSITION:relative;TOP:3px"> 操作 </nobr>
</div>
</td>
</tr><tr style="color:#000000;background-color:#f7f3ef;height:25px;">
<td>渠道经营事业部</td><td>部门</td><td>渠道网点建设发展与管理,商品采购和配送</td><td>
<div align="center" style="height:22px" class="coolButton" onclick="SelectSet(this,'23','')">
<nobr style="POSITION:relative;TOP:3px"> 操作 </nobr>
</div>
</td>
</tr><tr style="color:#000000;background-color:#FFFFFF;height:25px;">
<td>行情软件事业部</td><td>部门</td><td>证券,期货,外汇,黄金等数据信息服务和新闻交流服务</td><td>
<div align="center" style="height:22px" class="coolButton" onclick="SelectSet(this,'4588','')">
<nobr style="POSITION:relative;TOP:3px"> 操作 </nobr>
</div>
</td>
</tr><tr style="color:#000000;background-color:#f7f3ef;height:25px;">
<td>行政部</td><td>部门</td><td>总部的行政物资管理,人事文秘档案管理,财务管理</td><td>
<div align="center" style="height:22px" class="coolButton" onclick="SelectSet(this,'21','')">
<nobr style="POSITION:relative;TOP:3px"> 操作 </nobr>
</div>
</td>
</tr>
</table>
<script language="javascript">
// 新建岗位
function AddPosition()
{
var thisParentDeptId = ParentDeptId;
window.showModalDialog('Organsie_Add_Position.aspx?DeptId='+ thisParentDeptId, 'Organsie_Add_Position', 'scroll:no;help:no;status:no;dialogWidth:450px;dialogHeight:240px');
location.href(location.href);
}
// 新建部门
function AddDept()
{
var thisParentDeptId = ParentDeptId;
//alert(thisParentDeptId);
window.showModalDialog('Organsie_Add_Dept.aspx?ParentDeptId='+ thisParentDeptId, 'Organsie_Add_Dept', 'scroll:yes;help:no;status:no;dialogWidth:650px;dialogHeight:500px');
location.href(location.href);
}
// 删除
function ThisDel()
{
if(PositionId != "")
{
//alert("删除岗位");
if(confirm("是否真的要删除当前岗位?"))
{
var ThisPositionId = PositionId;
window.open('Organsie_Del_Position.aspx?PositionId='+ ThisPositionId, 'ThisDELS');
}
}
else
{
//alert("删除部门");
if(confirm("是否真的要删除当前部门?"))
{
var ThisDeptId = DeptId;
window.open('Organsie_Del_Dept.aspx?DeptId='+ ThisDeptId, 'ThisDELS');
}
}
}
// 移动
function ThisMove()
{
var thisDeptId = DeptId;
window.showModalDialog('Organise_Move_Dept.aspx?DeptId='+ thisDeptId, 'Organise_Move_Dept', 'scroll:yes;help:no;status:no;dialogWidth:650px;dialogHeight:500px');
parent.location.href(parent.location.href);
}
// 编辑
function ThisEdit()
{
if(PositionId != "")
{
//alert("编辑岗位");
var thisPositionId = PositionId;
window.showModalDialog('Organsie_Edit_Position.aspx?PositionId='+ thisPositionId, 'Organsie_Edit_Position', 'scroll:no;help:no;status:no;dialogWidth:450px;dialogHeight:240px');
location.href(location.href);
}
else
{
//alert("编辑部门");
var thisDeptId = DeptId;
window.showModalDialog('Organsie_Edit_Dept.aspx?DeptId='+ thisDeptId, 'Organsie_Edit_Dept', 'scroll:no;help:no;status:no;dialogWidth:650px;dialogHeight:500px');
location.href(location.href);
}
}
</script>
<iframe name="ThisDELS" style="display:none"></iframe>
</form>
</body>
</HTML>
已经实现了部分功能,现在是每点击一行都会高亮显示,可不可以作到点击下一行时让上一行复原?
{
e.Item.Attributes.Add("onclickmouse","DataGrid1.style.backgroundColor='dddddd';this.style.backgroundColor='#FFFFCC'");
}
Dim tr As TableRow
tr = e.Item()
If e.Item.ItemIndex <> -1 Then
tr.ID = e.Item.ItemIndex.ToString
tr.Attributes("onmouseover") = "this.style.backgroundColor='#C0C0FF';"
tr.Attributes("onmouseout") = "this.style.backgroundColor='#F2F8FF';"
End If
End Sub
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='#FFFFFF'");
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='#C0C0FF'");
}
是不是你要的效果?