1 <asp:LinkButton ID= " Delete " Text = " 删除 " runat = " server " CommandName= " Delete " CommandArgument = ' <%#Eval("ID","{0}") %> ' 2 OnCommand= " Delete_OnClick "/>
后台代码: protected void Delete_OnClick( object sender, CommandEventArgs ce ) { try { rt.Delete( int.Parse (ce.CommandArgument .ToString ()) ); if ( int.Parse( Session[ " GVState "].ToString( ) ) < 0 ) { Session[ " GridView "] = rt.select( ); GridView1.DataSource = rt.select( ); GridView1.DataBind( ); } else { Session[ " GridView "] = rt.select( txtKey.Text, cbIsInPos.Checked, FilePath ); GridView1.DataSource = rt.select( txtKey.Text, cbIsInPos.Checked, FilePath ); GridView1.DataBind( ); } } catch ( Exception ex ) { txtErrorMessage.Text = ex.Message; } }