您的位置:首页 > 其它

DataGrid行随鼠标移动变色及单击双击行事件处理

2013-01-24 17:23 337 查看
protected void Dgd_course_ItemDataBound(object sender, DataGridItemEventArgs e)

 {

            // 鼠标移动行变色

            e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#439be6'");

            e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");

           // 某行获取其中的某个字段的数值

            for (int i = 0; i < e.Item.Cells.Count; i++)

            {

                e.Item.Cells[i].Attributes.Add("onclick", "alert('" + e.Item.Cells[2].Text + "');"); // 单击获取

             //   e.Item.Cells[i].Attributes.Add("ondblclick", "alert('" + e.Item.Cells[2].Text + "');");//双击获取

              //  e.Item.Attributes.Add("onclick", "window.open('WebForm2.aspx?ZoneNo=" + e.Item.Cells[1].Text + "')");  

            }

        // 鼠标移动行变色

       if (e.Item.ItemIndex >= 0)

        {

            e.Item.Attributes["onmouseover"]="this.name=this.style.backgroundColor;this.style.backgroundColor='#CCCCFF';";

            e.Item.Attributes["onmouseout"]="this.style.backgroundColor=this.name;";

        }

}
http://book.4ucode.com/Study/Topic/1005313
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: