天天看點

Gridview中當滑鼠經過資料行時彈出一個層顯示資料

  JS代碼 頁面源碼 背景源碼 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { databind(); } } public void databind() { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrin gs["Conn"].ToString()); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "Select top 10 * From Customers"; SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); this.GridView1.DataSource = ds.Tables[0]; this.GridView1.DataKeyNames = new string[] { "CustomerID" }; this.GridView1.DataBind(); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", "Test('" + e.Row.Cells[0].Text + "','" + e.Row.Cells[1].Text + e.Row.Attributes.Add("onmouseout", "Hide()"); } }