很多人说很难,其实就这几行代码。只要在DataGrid1的ItemDataBound中写入下代码即可
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e){ if(e.Item.ItemIndex>=0) //此行可以删除掉 { //弹出窗口代码 e.Item.Attributes.Add("onclick","window.open(''''WebForm2.aspx?ZoneNo="+e.Item.Cells[0].Text+"'''','''''''',''''Toolbar=no'''')"); e.Item.Attributes.Add("onMouseOver","this.style.backgroundColor=''''#e9e9e9''''; this.style.cursor=''''hand'''';"); e.Item.Attributes.Add("onMouseOut","this.style.backgroundColor=''''#f7f7f7'''';"); }}
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18