Hej!Varför fungerar det inte!
Jag bifogar kod nedan som inte fungerar.....
Det är en "Add to order" funktion, den ska sätta in artikel nr, antal mm.
Det fungerar om jag inte lägger koden i en datalist, men jag vill även kunna göra det från en datalist.
Snälla, hjälp!
<code>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Trend.aspx.vb" Inherits="_default" %>
<script runat ="server" >
Private Sub reg(ByVal Source As Object, ByVal e As EventArgs)
ShowTrend_Insert.insert()
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="Trend" runat="server" ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"
SelectCommand="SELECT [TrendName] FROM [Trend]"></asp:SqlDataSource>
<asp:Label ID="label1" runat="server"></asp:Label>
</div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="Trend"
DataTextField="TrendName" DataValueField="TrendName">
</asp:DropDownList>
<asp:SqlDataSource ID="ShowTrend_Insert" runat="server" ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"
SelectCommand="SELECT * FROM [Article] WHERE ([Trend] = @Trend)"
InsertCommand='INSERT INTO [Order] (OrderNO, OrderDate, RetailStore_ID, Status, ArticleNo, Qty) VALUES (234,@OrderDate, @RetailStore_ID, @Status, @ArticleNo, @Qty)'>
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="Trend" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
<InsertParameters>
<asp:formparameter Name="OrderDate" formfield="OrderDate_Box" />
<asp:formparameter Name="RetailStore_ID" formfield="RetailStore_ID_Box" />
<asp:formparameter Name="Status" formfield="Status_Box" />
<asp:formparameter Name="ArticleNo" formfield="ArticleNo_Box" />
<asp:formparameter Name="Qty" FormField="Qty_Box" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"
ProviderName="<%$ ConnectionStrings:dbConnectionString.ProviderName %>"
SelectCommand="SELECT [OrderNO], [OrderDate], [RetailStore_ID], [Status], [ArticleNo], [Qty], [ID] FROM [Order]">
</asp:SqlDataSource>
<asp:TextBox ID="OrderNO_Box" runat="server"></asp:TextBox>
<asp:DataList ID="DataList1" runat="server" DataKeyField="ArtNo" DataSourceID="ShowTrend_Insert" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CaptionAlign="Top" CellPadding="3" CellSpacing="2" GridLines="Both" Height="760px" ShowFooter="False" ShowHeader="False" Width="392px">
<ItemTemplate>
ArtNo:
<br />
Price:
<asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>'></asp:Label><br />
Descriptions:
<asp:Label ID="DescriptionsLabel" runat="server" Text='<%# Eval("Descriptions") %>'></asp:Label><br />
OrderValue:<asp:Label ID="OrderValueLabel" runat="server" Text='<%# Eval("OrderValue") %>'></asp:Label>
<br />
Category1:
<asp:Label ID="Category1Label" runat="server" Text='<%# Eval("Category1") %>'></asp:Label><br />
Category2:
<asp:Label ID="Category2Label" runat="server" Text='<%# Eval("Category2") %>'></asp:Label><br />
Trend:
<asp:Label ID="TrendLabel" runat="server" Text='<%# Eval("Trend") %>'></asp:Label><br />
Visible:<asp:Label ID="VisibleLabel" runat="server" Text='<%# Eval("Visible") %>'></asp:Label><br />
Picture:
<br />
Stock_QTY:
<asp:Label ID="Stock_QTYLabel" runat="server" Text='<%# Eval("Stock_QTY") %>'></asp:Label><br />
<img src="231928.jpg" style="width: 160px; height: 152px" /><br />
Qty:
<asp:TextBox ID="Qty_Box" runat="server" Width="40px"></asp:TextBox><asp:Button ID="Button1" runat="server" Text="Buy" onclick="reg" />
</ItemTemplate>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<ItemStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<SelectedItemTemplate>
</SelectedItemTemplate>
</asp:DataList>
<asp:Repeater ID="Repeater1" runat="server">
</asp:Repeater>
<br />
<br />
</form>
</body>
</html>
</code>