从连接触发删除事件
前台代码:
后台代码:
Code
后台代码:
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;
}
}
{
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;
}
}