<script language="javascript" type="text/javascript">
function selectkk()
{
var item = document.getElementById('Select1');
// window.alert("sddsdsd");
if(item.selectedIndex!=0)
{
window.alert(item.options[item.selectedIndex].text);
}
else
{
window.alert("is 0");
}
}
function showDetail(cell1,cell2)
{
document.getElementById('td1').innerText="Name:"+cell1;
document.getElementById('td2').innerText="Address:"+cell2;
//获得鼠标的X轴的坐标
x = event.clientX + document.body.scrollLeft;
//获得鼠标的Y轴的坐标
y = event.clientY + document.body.scrollTop+10;
//显示弹出窗体
Popup.style.display="block";
//设置窗体的X,Y轴的坐标
Popup.style.left = x;
Popup.style.top = y;
}
//隐藏弹出窗体
function hide()
{
//隐藏窗体
Popup.style.display="none";
}
</script>
前台:
<table align="center" style="width: 55%; height: 237px; margin-right: 0px;">
<tr>
<td class="navBar" valign=top style="height:21px">
<asp:Label ID="Label1" runat="server"
style="text-align: center; font-size:medium; color: #FFFFFF"
Text="会员选择页面"></asp:Label>
</td>
</tr>
<tr>
<td style="vertical-align: top; text-align: left">
<asp:GridView ID="GridView1" runat="server" BackColor="White"
BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3"
GridLines="None" Width="100%" CellSpacing="1"
onrowdatabound="GridView1_RowDataBound" AllowPaging="True"
onrowcreated="GridView1_RowCreated" onrowcommand="GridView1_RowCommand">
<FooterStyle BackColor="#C6C3C6" HorizontalAlign="Center" ForeColor="Black" />
<RowStyle BackColor="#ECF4F7" HorizontalAlign="Center" ForeColor="Black" />
<EmptyDataRowStyle BackColor="#E3EBEE" BorderStyle="None" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF"
HorizontalAlign="Center" />
<EditRowStyle BorderStyle="Dotted" />
<AlternatingRowStyle HorizontalAlign="Center" />
</asp:GridView>
</td>
<td><div id="Popup" class="transparent" style="Z-INDEX:200;">
<table style="width: 300">
<tr>
<td style="width: 100px" id="td1">
</td>
</tr>
<tr>
<td style="width: 100px; height: 21px;" id="td2">
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
后台:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠标移动到每项时颜色交替效果
//e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';this.style.color='#003399'");
//e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#6699FF';this.style.color='#8C4510'");
//e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#A9A9A9';");
//e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#C0C0FF';this.style.cursor='hand';showDetail('" + e.Row.Cells[0].Text + "','" + e.Row.Cells[1].Text + "')");
e.Row.Attributes.Add("onmouseout", "hide();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";
}
}