DataGrid删除行

 首先是page_load:
  1. private void Page_Load(object sender, System.EventArgs e)   
  2. {   
  3. // 在此处放置用户代码以初始化页面   
  4. cmdSubmit.Attributes.Add("onClick","return confirm('确认要提交吗?');");   
  5.   
  6.   
  7. //参数传入   
  8. include.PublicClass pc=new spark.include.PublicClass();   
  9. try  
  10. {   
  11. TEWarrantyID=Request.QueryString.Get ("TEWarrantyID").Trim ();    
  12. if(TEWarrantyID == "")   
  13. {   
  14. TEWarrantyID = "0" ;   
  15. }   
  16. TEServerStationID = Session["SessionServerStationID"].ToString()  ;   
  17. }   
  18. catch  
  19. {   
  20. pc.GotoErrorPage("取得参数时出错。如果您是通过正常的途径来到这里,请与软件开发商联系。");   
  21. }   
  22.   
  23. //Response.Write("<INPUT type=hidden value=" + TEWarrantyID + " name=TEWarrantyID>");   
  24.   
  25. if(TEWarrantyID == "0"){cmdAddOrder.Disabled = true ;}   
  26.   
  27. //------判断权限   
  28. include.Purview pv=new spark.include.Purview();   
  29. bool canView = pv.CheckSecurity("3","001006003"); //如果是没有查看权限   
  30. bool canSave = pv.CheckSecurity2("3","001006001");   
  31. bool canSubmit = pv.CheckSecurity2("3","001006002");   
  32.   
  33. if(!Page.IsPostBack)   
  34. {   
  35. if(TEWarrantyID!="0")   
  36. {   
  37. get_warranty(TEWarrantyID) ;   //取相关信息,页面的布局是上面显示基本信息,下面是datagrid列表。   
  38. }   
  39. else  
  40. {   
  41. txtSubmitDate.Text = System.DateTime.Now.ToString("yyyy-MM-dd") ;   
  42. txtStartTranDate.Text = System.DateTime.Now.ToString("yyyy-MM-dd") ;   
  43. txtChgStartDate.Text  = System.DateTime.Now.ToString("yyyy-MM-dd") ;   
  44. txtChgEndDate.Text = System.DateTime.Now.ToString("yyyy-MM-dd") ;   
  45. }   
  46. //排序   
  47. ViewState["Sort"]="TAMain.MainStatus";   
  48. }   
  49. DataGridBind() ; //绑定   
  50.   
  51. }   
  52.   
  53. ///   
  54. 下面是DataGridBind:   
  55. include.ConDataBase cdb=new spark.include.ConDataBase ();   
  56. DataSet ds=new DataSet ();   
  57. string sql="********************" ; ///sql语句   
  58.   
  59. sql+="  order by ";   
  60. sql+=ViewState["Sort"].ToString();   
  61. //Response.Write(sql);   
  62. ds=cdb.reDataSet (sql);   
  63. DataGrid1.DataSource =ds.Tables [0];   
  64. DataGrid1.DataBind ();   
  65.   
  66. ///   
  67. ///最后是删除:   
  68. public void Grid_DeleteOrder(Object sender,System.Web.UI.WebControls.DataGridCommandEventArgs e)   
  69. {   
  70.     
  71. include.ConDataBase cdb=new spark.include.ConDataBase ();   
  72. DataSet ds= new DataSet ();   
  73. spark.settle.warranties theWarranty = new spark.settle.warranties() ;   
  74. string strSql ;   
  75. string strMainStatus ;   
  76. string TAMainID ;   
  77. TAMainID = e.Item.Cells[0].Text ;   
  78. strSql = "select * from TAMain where TAMainID = " + TAMainID  ;   
  79. ds = cdb.reDataSet(strSql) ;   
  80. strMainStatus = ds.Tables[0].Rows[0]["MainStatus"].ToString();   
  81.   
  82. if(strMainStatus == "30")   
  83. {   
  84. cdb.ExecuteSQL("删除sql where TAMainID = "+ TAMainID );   
  85. theWarranty.fresh(TEWarrantyID) ;    
  86. }   
  87. else    
  88. {   
  89. Response.Write("<SCRIPT language=javascript>alert('不能编辑此状态的索赔批次单。');</SCRIPT>") ;   
  90. }   
  91.   
  92.   
  93. DataGridBind();   
  94. Response.Redirect("warrantyShow.aspx?TEWarrantyID="+TEWarrantyID);  返回本页,本页的文件名即为WarrantyShow.aspx   
  95. }  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值