当前位置:编程学习 > C#/ASP.NET >>

帮帮忙改下,

<%@ import namespace="system.data" %>
<%@ import namespace="system.data.oledb" %>
<%@ Page Language="vb" Debug="true" %>


<script language="vb" runat="server">
    dim cart as datatable
  sub page_load(sender as object,e as event args)
    dimproductid as string="request.querystring("id")
    if session("shoppingcart")is nothing then
      newcarttable
       session("shopping")
    else
     cart=session("shoppingcart")
    end if
    if(not ispostback)then
      if(not productid="")then
        addtocart(productid)
      end if
    calculate total
    datagrid1.datasource="new dataview(cart)
    datagrid1.databind()
   end if
 end sub
sub new carttable()
   cart= newdatatable()
   cart.columns.add(new datacolumn("pid",gettype(string)))
   cart.columns.add(new datacolumn("pname",gettype(string)))
   cart.columns.add(new datacolumn("pprice",gettype(int32)))
   cart.columns.add(new datacolumn("pcount",gettype(int32)))
   cart.columns.add(new datacolumn("ptotal",gettype(int32)))
end sub
 
sub addtocart(bycal productid as string)
   dim strconn,strsql as string
   dim connn as oledbconnection
   dim adp as oledadataadapter
   dim ds as dataset
   dim dt as datatable
   strconn="provider=microsoft.jet.oledb.4.0;data source="&server.mappath("eshop.emdb")
   conn=new oledbconnection(s\trconn)
   strsql="select*from 商品 where productid='"&productid &"'"
   adp=new oloedbdataadapter(strsql,conn)
   ds=new dataset()
   adp.fill(ds,"商品")
   dt=ds.tables("商品")
   dim dr as data row=cart.new row()
   dr(0)=dr.rows(0)("productid")
   dr(1)=dr.rows(0)("productname")
   dr(2)=dt.rows(0)("price")
   dr(3)=1
   dr(4)=dr(2)*dr(3)
   cart.rows.add(dr)
end sub


sub calulatetotal()
   dim i as integer
   dim total as integer=0
   for i=0 to cart.rows.count-1
     total=total+cart.rows(i)(4)
   next
   id1total.text=total
end sub


sub btnupdate_click(sender as object,e as eventargs)
   dim i,j as integer
   dim _item as datagriditem
   dim delectitem(5) as string
 j=0
   for i=0 to datagrid1.items.count-1
   _item=datagrid1.items(i)
   dim counttext as textbox=_item.findcontrol("chkproductid")
   if productid check.checked then
     delecteitem(j)=i
     j=j+1
   end if 
   cart.rows(i)(3)=counttext.text
   cart.rows(i)(4)=cart.rows(i)(2)*cart.rows(i)(3)
   next
   for i=0 to j-1
     cart.rows(deleteitem(i)).delete
   next
   calculatetotal
   datagrid1.datasource=new dataview(cart)
   datagrid1.databind(0
 end sub
</script>
<html>
<body bgcolor="#eeeeee">
<center><font face="楷体" size="6">您的购物车</font><center><hr color="white">
<form runat=server>
<center>
   <asp:datagrid id="datagrid1" width="90%" headerstyle-horizontalalign="center"
   backcolor="#aaeecc" bordercolor="black" headerstyle-backcolor="#ccddee"
   cellpadding=3 cellspacing="0"
   font-name="verdana"font-size="8pt"
   autogeneratecolumns="false" runat="server">
<columns>
   <asp:templatclumn headertext="删除">
     <itemtemplate>
       <center><asp:checkbox id=chkproductid runat="server"/></center>
     </itemtemplate>
   </asp:templatecolumn>
   <asp:boundcolumn datafield="pname" Headertext="商品名称"/>
   <asp:boundcolumn datafield="pprice"headertext="单价"/>
   <asp:templatecolumn headertext="数量">
     <itemtemplate>
       <asp:textbox id=txtcount width="50" runat="server"
            text='<%#container.dataitem("pcount")%>'/>
     </itemtemplate>
    </asp:templatecolumn>
   <asp:boundcolumn datafield="ptotal" headertext="小计(元)"/>
  </columns>
   </asp:datagrid>
   <p>订单总金额:<asp:label id="id1total" runat="server"/>
   <p><asp:button id="update" runat="server" text="更新购物车" onclick="btnupdate_click"/>
   <br/><hr color="write"/>
   <a href="products.aspx">继续购物</a>
</center>
</form>
</body>
</html> --------------------编程问答-------------------- 楼主把这个编译一下。然后用反编译工具选C#察看,就翻译过来了。 --------------------编程问答-------------------- 改成啥样? --------------------编程问答--------------------  这机子不行啊,弄啥都冲突 --------------------编程问答-------------------- 这么长怎么入手,也不说具体点 --------------------编程问答-------------------- 错误 15 无法识别的命名空间“asp”。 D:\go\cart.aspx 99 5 杂项文件
--------------------编程问答-------------------- 所有的asp都无法识别 --------------------编程问答--------------------

我了个去,你这是啥噢,乱 ! --------------------编程问答-------------------- lz 也不描述下,哎,再看下结贴率,!!!0.00%,无语中。。。。
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,