void Item_Bound(Object sender, DataGridItemEventArgs e)
{
e.Item.Attributes.Add("onMouseOver","this.style.backgroundColor='#e9e9e9'; this.style.cursor='hand';");
e.Item.Attributes.Add("onMouseOut","this.style.backgroundColor='#ffffff';");
}<asp:DataGrid id="ItemsGrid" runat="server"
BorderColor="black"
BorderWidth="1"
CellPadding="3"
ShowFooter="true"
OnItemDataBound="Item_Bound"//************************
AutoGenerateColumns="true"> <HeaderStyle BackColor="#00aaaa">
</HeaderStyle> <FooterStyle BackColor="#00aaaa">
</FooterStyle>
</asp:DataGrid>
{
e.Item.Attributes.Add("onMouseOver","this.style.backgroundColor='#e9e9e9'; this.style.cursor='hand';");
e.Item.Attributes.Add("onMouseOut","this.style.backgroundColor='#ffffff';");
}<asp:DataGrid id="ItemsGrid" runat="server"
BorderColor="black"
BorderWidth="1"
CellPadding="3"
ShowFooter="true"
OnItemDataBound="Item_Bound"//************************
AutoGenerateColumns="true"> <HeaderStyle BackColor="#00aaaa">
</HeaderStyle> <FooterStyle BackColor="#00aaaa">
</FooterStyle>
</asp:DataGrid>
{
this.ClueDatagrid.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgAddClick_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load); }public void dgAddClick_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
//如果是交替项和项
if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
//为数据项添加鼠标单击属性
// e.Item.Attributes.Add("onMouseOver","this.style.backgroundColor='#93BEB6'; this.style.cursor='hand';");
// e.Item.Attributes.Add("onMouseOut","this.style.backgroundColor='#ffffff';"); e.Item.Attributes.Add("onMouseOver","this.style.cursor='hand';this.style.backgroundColor='#E8F4FF'");
e.Item.Attributes.Add("onMouseOut"," this.style.backgroundColor=''");
e.Item.Attributes.Add("ondblClick", "window.open('ClueInfo_BySuspectID.aspx?ID="+this.ClueDatagrid.DataKeys[e.Item.ItemIndex].ToString()+"','','','resizable=yes,location=no,toolbar=no,height=600')");
}
}