[ASP.NET] DataGrid mouse through a perception and click on the line pop-up window

xiaoxiao2021-03-06  99

Many people say it is difficult, in fact, this few lines of code. As long as you write the code in the itemDatabase of DataGrid1

Private void DataGrid1_itemdatabase (ibject sender, system.web.ui.webcontrols.dataGriditeMeventargs e) {if (E.Item.itemindex> = 0) // This line can delete {// pop-up code 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'; ");}} If you want the Click to enter the editing state, you can also add a column EDIT template column in DataGrid1, and set the column to hide the status, then add the following code in the itemDatabase event (such as 5 list as an edit column) LinkButton OSELECT = (LinkButton) E.Item.cells [4] .controls [0]; E.Item.attributes.add ("OnClick", Page.GetPostBackClienthyPerLink (OsterLect, ")); Click on the line as a click of the Edit column.

转载请注明原文地址:https://www.9cbs.com/read-103052.html

New Post(0)