问题描述
绑定隐藏字段CartID希望的效果是如果点击删除选中,那勾选到复选框的记录就被删除后台文件是这样的protectedvoidLinkButtonDelete_Click(objectsender,EventArgse){CartBLLcartBLL=newCartBLL();for(inti=0;i<=GridView1.Rows.Count-1;i++){CheckBoxCheckBoxSelect=(CheckBox)GridView1.Rows[i].FindControl("CheckBoxSelect");if(CheckBoxSelect.Checked==true){intcartID=GridView1.DataKeys[]["CartID"].ToString()//主要不知道这里的DataKeys怎么取到我当前行····boolresult=cartBLL.RemoveFromCart(cartID);if(result)ClientScript.RegisterClientScriptBlock(Page.GetType(),"","<script>alert('删除商品成功!')</script>");elseClientScript.RegisterClientScriptBlock(Page.GetType(),"","<script>alert('删除商品失败!')</script>");}}
解决方案
解决方案二:
参考
时间: 2024-12-13 14:37:10