protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e) { ListItemType itemType = (ListItemType)e.Item.ItemType; if ((itemType != ListItemType.Header) && (itemType != ListItemType.Footer) && (itemType != ListItemType.Separator)) { //设置行效果 //e.Item.Attributes.Add("onclick", "RowClick(this)"); //e.Item.Attributes.Add("OnDblClick", "RowDbClick(this)"); LinkButton lnkbtn = (LinkButton)e.Item.FindControl("LinkButton1"); lnkbtn.CommandArgument = e.Item.ItemIndex.ToString(); var k = DataGrid1.DataKeys[int.Parse(lnkbtn.CommandArgument)].ToString(); //为该按钮添加CLICK事件,调用JAVASCRIPT脚本 lnkbtn.Attributes.Add("onclick", "javascript:showModalDialog('yearedit.aspx?inteid=" + k + "',window,'dialogWidth:300px; dialogHeight:300px;help:0;status:0;resizeable:1;');"); e.Item.Style.Add("Cursor", "Hand"); } }