从产品购物车中删除该行,我正在使用gridview来显示产品 [英] delete the row from products shopping cart i am using gridview to display products

查看:54
本文介绍了从产品购物车中删除该行,我正在使用gridview来显示产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi

我想从网格视图而不是从数据库中删除行.

就像您看到任何电子商务站点一样,他们将拥有一个购物车,其中将显示选定的产品.如果我想删除我选择的产品之一,它只会从购物车中删除而不是从数据库中删除.我在这里有同样的问题,我正在使用gridview显示选定的产品.

hi

i want to delete the row from grid view not from database.

like if u see any e- commerce site they will have a shopping cart where the will display selected products. if i want to delete one of my selected products.its gets deleted from the shopping cart only not from database. i have the same problem here i am using gridview to display the selected products.

推荐答案



有很多实现方法.

我的建议之一是将选定的值存储在会话变量中,然后您可以在用户付款之前随时删除或添加.

在这里,我提供了用于将数据存储在会话变量中的示例代码

Hi,

there are so many ways to implement that .

one of my suggestion is store selected values in session variable then you can delete or add when ever you want before user make payment.

Here I''m providing sample code for to store data in session variable

   //On click of AddToCart 
  DataTable dt=new DataTable(); 
  if(Session["Cart"].tostring()=="")
{
     dt.columns.Add("itemid");
     dt.columns.Add("itemcost");
     dt.columns.Add("itemcount");
}
else
{
   dt=(DataTable)Session["Cart"];
}
   addData(dt,itemid,itemcost,itemcount);
   Session["Cart"]=dt;
 //dt is datatable object which holds the selected items information.



在上面的代码中,addData()是自定义方法,可将行添加到dt

在这里,您可以随时从该数据中删除行



In the above code addData() is custom method to add row to dt

Here you can delete row from that data whenever you want

 //On delete click
 DataTable dt=new DataTable(); 
 dt=(DataTable)Session["Cart"];
 dr=dt.newrow();

 dr[0]=itemid;//Here itemid means which item you want to delete come from delete button argument
dr[1]=itemcost;
dr[2]=itemcount;
    dt.Rows.Remove(dr);
  Session["Cart"]=dt;



这仅是示例,您可以实现此功能以实现您的要求.

最好的



This just for sample you can implement this for achieve your requirement.

All the Best


这篇关于从产品购物车中删除该行,我正在使用gridview来显示产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆