It is difficult for many people to say that these lines of code actually exist. You only need to write the code in itemdatabound of datagrid1.
Private void maid (Object sender, system. Web. UI. webcontrols. datagriditemeventargs E)
{
If (E. Item. itemindex> = 0) // This row can be deleted.
{
// Pop-up window 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 to click a row to enter the editing status, you can also add an edit template column in The datagrid1 and set the column to the hidden status, then add the following code to the itemdatabound event (for example, column 5th is the edit column)
Linkbutton oselect = (linkbutton) E. Item. cells [4]. controls [0];
E. Item. Attributes. Add ("onclick", page. getpostbackclienthyperlink (oselect ,""));
In this way, clicking the row is like clicking the edit column.