When the mouse goes through a row, it is highlighted to increase the visual effect,CodeAs follows:
If (E. Item. itemtype = listitemtype. Item | E. Item. itemtype = listitemtype. alternatingitem)
{
E. Item. Attributes. Add ("onmouseover", "c = This. style. backgroundcolor; this. style. backgroundcolor = '#9ccbf7 '");
E. Item. Attributes. Add ("onmouseout", "This. style. backgroundcolor = C ");
}
The row color after the mouse goes through is #9ccbf7, And the mouse is moved back to the original color. Here, use C to save the original Top value first!
Put the above Code in the itemdatabind event.
DataGrid deletion confirmation
Private void maid (Object sender, system. Web. UI. webcontrols. datagriditemeventargs E)
{
Linkbutton MYDEL = (linkbutton) E. Item. findcontrol ("btndel ");
If (MYDEL! = NULL)
{
MYDEL. Attributes. Add ("onclick", "Return confirm ('Are you sure you want to delete it? ');");
}
}
DataGrid sorting
Private void datagrid1_sortcommand (Object source, system. Web. UI. webcontrols. datagridsortcommandeventargs E)
{
Dataset DS = new dataset ();
DS = dB. getdataset ("select * From mytab ");
Dataview DV = Ds. Tables [0]. defaultview;
DV. Sort = E. sortexpression;
Datagrid1. datasource = DV;
Datagrid1. databind ();
}
Bidirectional sorting...
If (viewstate ["order"] = NULL)
{
Viewstate ["order"] = "ASC ";
}
Else
{
If (viewstate ["order"]. tostring () = "ASC ")
{
Viewstate ["order"] = "DESC ";
}
Else
{
Viewstate ["order"] = "ASC ";
}
}< br> sqlconnection mycon = dB. creatcon ();
sqldataadapter da = new sqldataadapter ("select * from student order by studentid DESC", mycon);
dataset DS = new dataset ();
da. fill (DS, "tabnew");
dataview DV = Ds. tables [0]. defaultview;
DV. sort = E. sortexpression + "" + viewstate ["order"]. tostring ();
maid = DV;
maid. databind ();