谢谢帮忙! private void Grid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType=e.Item.ItemType; e.Item.Attributes["onmouseover"]="javascript:this.style.backgroundColor='#0099cc'"; if (itemType==ListItemType.Item)
{
e.Item.Attributes["onmouseout"]="javascript:this.style.backgroundColor='#FFFFFF'";
} else if(itemType==ListItemType.AlternatingItem)
{
e.Item.Attributes["onmouseout"]="javascript:this.style.backgroundColor='#EFEFEF'";
} if (e.Item.ItemType == ListItemType.Item ||e.Item.ItemType == ListItemType.AlternatingItem) 
{
ImageButton button = (ImageButton) e.Item.FindControl("delbutton");
button.Attributes.Add ("onclick","return confirm (\"确定要删除此项记录吗?\");");
}
}

解决方案 »

  1.   

    2005中用的是gridview,总会要改吧,我把代码放进去是不对的
      

  2.   

    05中没有ItemDataBound 替换成了 RowDataBound 参数也变了
      

  3.   

    我知道 是RowDataBound,但是其它也修改,但是不会!请哪位老大帮忙!
      

  4.   

    vs2005也是可以使用DataGrid的
    一点问题都没有
    如果要用GridView的话
    还是要改的
    http://gridviewguy.com/ArticleDetails.aspx?articleID=172
    Changing GridView Row Color OnMouseOver确认删除的话,只要把按钮列改称模板列,在OnClientClick中加入js就ok了。
      

  5.   

    已经找到了答案: protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            e.Row.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#0099cc'";
            if (e.Row.RowType == DataControlRowType.DataRow)
            {            if (e.Row.RowState == DataControlRowState.Alternate)                              e.Row.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#E0E0E0'";
                else
                    e.Row.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#FFFFFF'";            LinkButton button = (LinkButton)e.Row.FindControl("LinkButton1");
                button.Attributes.Add("onclick", "return confirm (\"确定要删除?\");");        }
        }
      

  6.   

    2005中到底有没有datagrid啊?给个明确的答案撒!找了半天都没看到,