问题描述
问题描述:数据库购物卡表中有个列IsLock值为1或者0,如何筛选IsLock=0的数据,就是说下拉菜单不显示IsLock=1的购物卡,这个应该如何实现,尽量具体点,本人小白,谢谢了。。。///<summary>///绑定会员的购物卡列表///</summary>privatevoidBindUserCardList(){DataTabledt=DatabaseProvider.GetInstance().GetShopCardSearch(-1,base.LoginID);dt=utils.DeCodeCardPassword(dt);utils.BindSelect(ddlCardList,dt.DefaultView,"-请选择您的购物卡-","","Number","Password","");}
解决方案
解决方案二:
不能用SQL语句去实现么?查询的时候IsLock<>1
解决方案三:
在GetShopCardSearch中通过sql实现或或使用dataviewm过滤islock为1的数据
解决方案四:
最好在sql里过滤,要么就对DataTable进行筛选DataRow[]drs=dt.Select("IsLock=0");
解决方案五:
查询的时候处理就行了,而且没必要查出所有的数据,然后再通过代码来筛选.
解决方案六:
///<summary>///绑定会员的购物卡列表///</summary>privatevoidBindUserCardList(){DataTabledt=DatabaseProvider.GetInstance().GetShopCardSearch(-1,base.LoginID);dt=utils.DeCodeCardPassword(dt);dt=dt.Select("IsLock=0");utils.BindSelect(ddlCardList,dt.DefaultView,"-请选择您的购物卡-","","Number","Password","");}
解决方案七:
写错了
解决方案八:
谁能帮我写个正确的????
解决方案九:
usingSystem;usingSystem.Data;usingV5Shop.Common;usingV5Shop.Data;usingV5Shop.Web.UI;namespaceV5Shop.NewMember{publicpartialclassUser_ShopCard_Payment:TplPage{publicstringstrBackUrl;protectedvoidPage_Load(objectsender,EventArgse){//this.Title="购物卡支付";BindData();}///<summary>///数据绑定///</summary>privatevoidBindData(){stringnumber=utils.V5ShopRequest("number");stringprice=utils.V5ShopRequest("price");strBackUrl="User_UserOrder_Operate.aspx?OrderNumber="+number;this.lblOrderNumber.Text=number;this.lblTotalPrice.Text=price;if(DbHelper.ExecuteDataTable("SELECT*FROMWeb_ShopCardWHEREUserName='"+base.LoginID+"'").Rows.Count>0){this.lblCardPrise.Text=DbHelper.ExecuteDataTable("SELECT*FROMWeb_ShopCardWHEREUserName='"+base.LoginID+"'").Rows[0]["CardPrise"].ToString();}else{this.lblCardPrise.Text="0.00";}if(base.LoginID!=""){BindUserCardList();}else{ddlCardList.Visible=false;}}///<summary>///绑定会员的购物卡列表///</summary>privatevoidBindUserCardList(){DataTabledt=DatabaseProvider.GetInstance().GetShopCardSearch(-1,base.LoginID);dt=utils.DeCodeCardPassword(dt);utils.BindSelect(ddlCardList,dt.DefaultView,"-请选择您的购物卡-","","Number","Password","");}///<summary>///支付事件///</summary>///<paramname="sender"></param>///<paramname="e"></param>protectedvoidbtnSubmit_Click(objectsender,EventArgse){stringCardMoney="0";//stringFrozen="0";stringOrderNumber=this.lblOrderNumber.Text;stringUserCard=this.txtCardNumber.Text;stringTotalPrice=this.lblTotalPrice.Text;DataTabledt=DatabaseProvider.GetInstance().GetShopCardByNamePass(this.txtCardNumber.Text,"");dt=utils.DeCodeCardPassword(dt);if(dt==null||dt.Rows.Count<=0){utils.JsAlert(transJsContent(this.lblMiss.Text));}else{//判断密码是否正确if(dt.Rows[0]["Password"].ToString()!=this.txtPassword.Text){utils.JsAlert(transJsContent(this.lblMiss.Text));}else{if(dt.Rows[0]["IsLock"].ToString()=="0"){//获取用户卡金额CardMoney=dt.Rows[0]["CardPrise"].ToString();//判断卡内钱够不够if(decimal.Parse(this.lblTotalPrice.Text)<=decimal.Parse(CardMoney)){//扣卡内金额DatabaseProvider.GetInstance().UpdateShopCardInfo(UserCard,TotalPrice);//写记录日志DatabaseProvider.GetInstance().InsertShopCardLog(UserCard,TotalPrice,OrderNumber,base.LoginID);//修改订单状态DatabaseProvider.GetInstance().UpdateOrderState(OrderNumber,"1","");//支付成功utils.JsAlert(transJsContent(lblSuccess.Text),"User_UserOrder_Operate.aspx?OrderNumber="+this.lblOrderNumber.Text);}else{//卡内金额不足utils.JsAlert("当前购物卡剩余金额为:"+CardMoney+","+transJsContent(this.lblCardNoFull.Text),"User_UserOrder_Operate.aspx?OrderNumber="+this.lblOrderNumber.Text);//ModBy钟登科2008-11-27}}else{utils.JsAlert("该购物卡已被锁定,请联系客服人员!");}}}}protectedvoidbtnRedirect_Click(objectsender,EventArgse){Response.Redirect("User_UserOrder_Operate.aspx?OrderNumber="+this.lblOrderNumber.Text);}protectedvoidButton1_Click(objectsender,EventArgse){Response.Redirect("User_UserOrder_Operate.aspx?OrderNumber="+this.lblOrderNumber.Text);}}}
解决方案十:
引用2楼wuyq11的回复:
在GetShopCardSearch中通过sql实现或或使用dataviewm过滤islock为1的数据
怎么写???