gridview選發行彈出層 模板列

 

前臺

    
<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>
    
<style type="text/css">
     .transparent 
     
{ BORDER-RIGHT: indianred 1px solid; 
     BORDER-TOP
: indianred 1px solid;
      DISPLAY
: none; FILTER: alpha(opacity=85);
       BORDER-LEFT
: indianred 1px solid; 
       BORDER-BOTTOM
: indianred 1px solid; 
       POSITION
: absolute; 
       BACKGROUND-COLOR
: infobackground; 
       font-color;red;
}
   
       
       
</style>
    
<div>
        
<table border="1" style="width: 50%">
  
           
   
            
<tr>
                
<td style="width: 100px; height: 30px;">
                
</td>
                
<td style="width: 100px; height: 30px;">
                
                    
                    
&nbsp;<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowDataBound="GridView1_RowDataBound"
                        Width
="326px" >
                        
<Columns>
                            
<asp:BoundField DataField="user_id" HeaderText="user_id" />
                            
<asp:BoundField DataField="email" HeaderText="email" />
                        
</Columns>
                    
</asp:GridView>
                       
                
</td>
                
<td style="width: 300; height: 30px;">
                    
<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>
    
</div>

 

 

後臺
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class EtsBBS_Default2 : System.Web.UI.Page
{
    
protected void Page_Load(object sender, EventArgs e)
    {
        
if (!IsPostBack)
        {
            getDate();
        }
    }

    
public void getDate()
    {


        
string sql = "select user_id ,user_name,email from mdsets_bbs_users";
        DataSet ds 
= OracleHelper.GetDS(sql);
        GridView1.DataSource 
= ds; 
        GridView1.DataBind();
    }
    
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='#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;");


        }
    }
   
}

 

posted @ 2010-11-12 14:13  你妹的sb  阅读(325)  评论(0编辑  收藏  举报
百度一下