private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemIndex<0) return;
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='48d1cc'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");
e.Item.Attributes.Add("OnClick",Page.GetPostBackClientEvent(e.Item.Cells[0].Controls[0],String.Empty)); } }
{
if(e.Item.ItemIndex<0) return;
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='48d1cc'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");
e.Item.Attributes.Add("OnClick",Page.GetPostBackClientEvent(e.Item.Cells[0].Controls[0],String.Empty)); } }
你在aspx中定义了OnItemDataBound,就用protected ,如果是在cs中委托的,就用private