Aspx: <asp: gridview id = "mygvclass" runat = "server" autogeneratecolumns = "false" width = "100%" datakeynames = "ID" onrowcancelingedit = "inline" onrowediting = "inline" onrowupdating = "mygvclass_rowupdating "onrowdeleting =" mygvclass_rowdeleting "bordercolor =" # cccccc "borderstyle =" solid "borderwidth =" 1px ">
<Columns>
<Asp: boundfield datafield = "ID" headertext = "no." readonly = "true">
<Itemstyle horizontalalign = "center"/>
<Headerstyle horizontalalign = "center" width = "10%"/> </ASP: boundfield>
<Asp: boundfield datafield = "classname" headertext = "topic name">
<Itemstyle horizontalalign = "Left"/>
<Headerstyle horizontalalign = "Left" width = "52%" type = "codeph" text = "codeph"/>
<Controlstyle width = "80%" type = "codeph" text = "/codeph"/>
</ASP: boundfield>
<Asp: boundfield datafield = "stime" headertext = "Operation Time" readonly = "true">
<Itemstyle horizontalalign = "center"/>
<Headerstyle horizontalalign = "center" width = "20%"/> </ASP: boundfield>
<Asp: commandfield headertext = "operation" showeditbutton = "true">
<Headerstyle horizontalalign = "center" width = "12%"/>
<Itemstyle horizontalalign = "center"/> </ASP: commandfield>
<Asp: templatefield headertext = "delete" showheader = "false">
<Itemstyle horizontalalign = "center"/>
<Headerstyle horizontalalign = "center" width = "6%"/>
<Itemtemplate>
<Asp: linkbutton id = "linkbutton1" onclientclick = "Return confirm ('Are you sure you want to delete this record? '); "Runat =" server "causesvalidation =" false "commandname =" delete"
TEXT = "delete"> </ASP: linkbutton>
</Itemtemplate>
</ASP: templatefield>
</Columns>
<Headerstyle backcolor = "lightgray"/>
</ASP: gridview>
CS: protected void mygvclass_rowediting (Object sender, gridviewediteventargs E)
{
Mygvclass. editindex = E. neweditindex;
This. mygvclass. editrowstyle. backcolor = color. aliceblue;
Bindata ();
}
Protected void mygvclass_rowcancelingedit (Object sender, gridviewcancelediteventargs E)
{
Mygvclass. editindex =-1;
Bindata ();
}
Protected void mygvclass_rowupdating (Object sender, gridviewupdateeventargs E)
{
String Strid = This. mygvclass. datakeys [E. rowindex]. value. tostring ();
String strclassname = (textbox) (mygvclass. Rows [E. rowindex]. cells [1]. controls [0]). Text. Trim (). tostring ();
Webclass. articlelist TMP = new webclass. articlelist ();
TMP. editclass (strclassname, Strid );
Mygvclass. editindex =-1;
Bindata ();
}
Protected void mygvclass_rowdeleting (Object sender, gridviewdeleteeventargs E)
{
String Strid = This. mygvclass. datakeys [E. rowindex]. value. tostring ();
Webclass. articlelist TMP = new webclass. articlelist ();
TMP. delclass (Strid );
Mygvclass. editindex =-1;
Bindata ();
}