1. Bind The gridview and perform paging operations
Protected void gv_bind ()
{
Datatable dt = new datatable ();
If (txt_search.text.trim () = "")
Dt = g_cc.getlist (this. getuserid (). Tables [0];
Else
Dt = g_cc.getsearch (txt_search.text.trim (), this. getuserid ());
Pageddatasource objpds = new pageddatasource ();
Aspnetpager1.recordcount = DT. Rows. count;
Lbl_count.text = DT. Rows. Count. tostring ();
Objpds. datasource = DT. defaultview;
Objpds. allowpaging = true;
Objpds. currentpageindex = aspnetpager1.currentpageindex-1;
Objpps. pagesize = aspnetpager1.pagesize;
Gv_searchdetail.datasource = objpds;
Gv_searchdetail.datakeynames = new string [] {"ID "};
Gv_searchdetail.databind ();
}
2. Mouse Effect
Protected void gv_searchdetail_rowdatabound (Object sender, gridviewroweventargs E)
{
// First determine whether it is a data row
If (E. Row. rowtype = datacontrolrowtype. datarow)
{
// Change the background color when the mouse stays
E. Row. Attributes. Add ("onmouseover", "c = This. style. backgroundcolor; this. style. backgroundcolor = '# dbebfc '");
// Restore the background color when you move the mouse away.
E. Row. Attributes. Add ("onmouseout", "This. style. backgroundcolor = C ");
}
}
3 events in the Departure Control
Protected void gv_searchdetail_rowcommand (Object sender, gridviewcommandeventargs E)
{
If (E. commandname = "Del ")
{
String id = E. commandargument. tostring ();
G_cc.delete (Int. parse (ID ));
Gv_bind ();
}
}