62,041
社区成员
发帖
与我相关
我的任务
分享
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="../jquery/jquery.js"></script>
<script type="text/javascript">
$(function(){
$("#GridView1").find("tr").click(function(){
$("#div1").show();
$("#div1").css({ position: "absolute", background: "blue" });
$("#div1").css("left",$("#content").offset().left+$("#GridView1").width()/2-$("#div1").width()/2);//这里的弹出框我用的是GridView1正中
$("#div1").css("top",$("#content").offset().top+$("#GridView1").height()/2-$("#div1").height()/2);
$(this).find("td").each(function(i){
switch(i)
{
case 1:$("#table1").find("#tbName").val($(this).text());break;
case 2:$("#table1").find("#tbImg").val($(this).text());break;
case 3:$("#table1").find("#tbTime").val($(this).text());break;
}
});//遍历选中行cell中的text
});
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="content">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
SortExpression="id" />
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
<asp:BoundField DataField="mapImage" HeaderText="mapImage" SortExpression="mapImage" />
<asp:BoundField DataField="createtime" HeaderText="createtime" SortExpression="createtime" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=.;Initial Catalog=xxx;Integrated Security=True"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT [id], [name], [mapImage], [createtime] FROM [panoImg]">
</asp:SqlDataSource>
<div id="div1" style="display:none">
<table id="table1">
<tr><td>XXX:<asp:TextBox ID="tbName" runat="server"></asp:TextBox></td></tr>
<tr><td>XXX:<asp:TextBox ID="tbImg" runat="server"></asp:TextBox></td></tr>
<tr><td>XXX:<asp:TextBox ID="tbTime" runat="server"></asp:TextBox></td></tr>
</table></div>
</div>
</form>
</body>
</html>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int i = -1; i < GridView1.Rows.Count; i++)
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
}
string title1="姓名";
string title2="编号";
string title3="密码";
string title4="性别";
tr_link.Attributes.Add("onclick", "overlib('" + title1 + "','" + title2 + "','" + title3 + "','" + title4 + "')");
//这里不用多说了,JS代码
<script language="JavaScript">
//----------------------写HTML代码----------------------
var changdi="<table style='margin:0 0 0 0;border:solid 1px #009933;background:#ffffff''><tr><td align='center' vlign='middle'><img src='../website/image/tips.jpg' width=50 height=50></td><td align='center' vlign='middle'><font color='green' size='6'>这里写你需要显示的东西,也重新写这个变量里面所有的HTML</font></td></tr></table>";
//------------------------------------------------------
var isIE = document.all?true:false;
function overlib(tipcontent)
{
customdiv = document.getElementById("overDiv");
customdiv2 = document.getElementById("overDiv2");
customdiv.innerHTML = tipcontent;
var tleft=document.body.scrollLeft+window.event.clientX;
var ttop=document.body.scrollTop+window.event.clientY;
if(document.body.clientWidth < 300)
{
customdiv.style.left = 2;
customdiv2.style.left = 2;
}
else if (tleft > document.body.clientWidth-200)
{
customdiv.style.left = tleft-175;
customdiv2.style.left = tleft-175;
}
else
{
customdiv.style.left = tleft + 10;
customdiv2.style.left = tleft + 10;
}
if(document.body.clientHeight < 100)
{
customdiv.style.top = 25;
customdiv2.style.top = 25;
}
else if(ttop > document.body.clientHeight -55)
{
customdiv.style.top = ttop - 55;
customdiv2.style.top = ttop - 55;
}
else
{
customdiv.style.top = ttop + 10;
customdiv2.style.top = ttop + 10;
}
customdiv2.style.width=customdiv.clientWidth;
customdiv2.style.height=customdiv.clientHeight;
customdiv.style.visibility = 'visible';
customdiv2.style.visibility = 'visible';
}
function nd()
{
customdiv = document.getElementById("overDiv");
customdiv2 = document.getElementById("overDiv2");
customdiv.style.width=0;
customdiv.style.height=0;
customdiv.style.visibility = 'hidden';
customdiv2.style.visibility = 'hidden';
}
function b(v)
{
window.status=v
};
</script>
//这里可以放在网页的任何地方,一个IFRAME,一个DIV,组合起来可以遮挡SELECT
<div id="overDiv" style="position:absolute; visibility:hidden;z-index:100;padding:0 0 0 0;background:#FDFEF9;text-align:left;font-size:12px;">
</div>
<iframe id="overDiv2" src="" scrolling="no" frameborder="no"style="position:absolute; visibility:hidden;z-index:99;filter: Alpha(style=0,opacity=0) "> </iframe>
//鼠标悬停调用
onMouseOver="return overlib(changdi)" onMouseOut="return nd();"