怎么删除购物车内商品
发布时间:2011-06-22 15:35:32 文章来源:www.iduyao.cn 采编人员:星星草
如何删除购物车内商品。
如题。购物车是用DataGrid.第一列绑定商品id.最后一列绑定按纽-删除。如何实现点击删除,就把购物车内的商品去掉?谢谢·
------解决方案--------------------
for (int i = 0; i < dataGrid.SelectedRows.Count; i++)
{
//同时删除掉TUserAccount,TNoticeUser,TNoticeGroupLink中相关联的数据。
string UserID = dataGridView1.Rows[dataGrid.SelectedRows[i].Index].Cells[ "UserID "].Value.ToString();
string sql = string.Format( "delete from TUserAccount where UserID = '{0} ' "+
" delete from TNoticeUser where UserID = '{1} ' "+
" delete from TNoticeUser where UserID = '{2} ' ", UserID, UserID, UserID);
dtfactory.UpDataRecord(sql);
}
------解决方案--------------------
/// <summary>
/// DATAGRID的删除按钮
/// </summary>
private void dtgList_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
textCD tcd=new textCD();
string fvt_strMoney = " ";
int fvt_intWeight = 0;
DataTable DT_MyCar = (DataTable)Session[ "mytable "];//将Session中的值赋给新定义的DataTable
TextBox TB_NewNum = (TextBox)e.Item.FindControl( "Num ");
for(int i=0;i <DT_MyCar.Rows.Count;i++)
{
if(DT_MyCar.Rows[i][ "商品ID "].ToString()==e.Item.Cells[0].Text)
{
fvt_strMoney = DT_MyCar.Rows[i][ "金额 "].ToString();
fvt_intWeight = Convert.ToInt32(DT_MyCar.Rows[i][ "重量 "]);
}
}
this.lbl_BuyNum.Text = Convert.ToString(Convert.ToInt32(this.lbl_BuyNum.Text) - Convert.ToInt32(tcd.ToDBC(TB_NewNum.Text)));
this.lbl_AllMoney.Text = Convert.ToString(Convert.ToDecimal(this.lbl_AllMoney.Text) - Convert.ToDecimal(fvt_strMoney));
this.lbl_Weight.Text = Convert.ToString(Convert.ToInt32(this.lbl_Weight.Text) - fvt_intWeight);
DT_MyCar.Rows[Convert.ToInt32(e.Item.ItemIndex)].Delete();//执行删除行
DT_MyCar.AcceptChanges();
Session[ "mytable "] = DT_MyCar;//将最新的结果返还给Session
this.dtgList.DataSource = DT_MyCar;//绑定DataGrid的数据源
this.dtgList.DataBind();
Page_Load(null,null);
}
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
其他相似内容:
-
页面基类PageBase.cs代码,实现系统进入权限判断 这样思路有问题吗?
pagebase.cs 代码
C# code
public class PageBase:System.We...
-
linq中的表连接语句???
例如:album,artist,genre这三个表的连接语句。。谢谢
------解决方案--------------------
public PagedList<...
-
为什么Repeater控件生成的HTML有很多空行?
效果如下,每个超链接之后都自动换行。
<a target="_blank" href='http://v.gamefy.cn/v...
-
关于模式窗口关闭的问题(在线等,解答立刻结贴给分)
功能什么都做完了。问题有二:
1.关闭的时候父窗口不刷新。于是我在吊用模式窗口的...
-
ASP.NET 中为什么要把相对路径处理成 绝对路径
处理函数如下:
C# code
// Builds an absolute URL
private static strin...
-
asp.net里面像QQ相册那样列表然后预览的jquery特效
asp.net里面像QQ相册那样列表然后预览的jquery特效
谁有这样的完整例子,...
-
求高手共同破解JQGrid 4.1 for Asp.net(比GridView强大)
软件名称:jqSuite(此插件比asp.net自带GridView强大的多,但只能使用30天)
...
-
急!!!在线等 asp.net中页面传值刷新不跳转新建窗口
C# code
<asp:TemplateField HeaderText="操作管...
-
请教:asp.net 导出word文件思路
我要从数据库取数据,写到word文件里,请教高手指点.多谢了!
------解决方案--------------------...
-
jqGrid4定义按钮查询(用过jqGrid的高手请进,在线等)
如图,json格式数据已加载,如果不用JQGrid底部工具栏上查询按钮查询,用最上面自己...