<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [delikatesse]"></asp:SqlDataSource> <div id="ekstra_vare"> <asp:DataList ID="VisDeli" runat="server" RepeatLayout="Table" RepeatColumns="4" DataSourceID="SqlDataSource1" OnItemDataBound="VisDeli_ItemDataBound" CellSpacing="5" CssClass="tabel1" > <HeaderTemplate> <p class="overskrift_bestil">Vælg tilbehør</p> </HeaderTemplate> <ItemTemplate> <td><asp:TextBox ID="TextBox_deli" runat="server" Width="15" Height="15"></asp:TextBox></td> <td><p><%#Eval("deli_navn") %></p> <td><p><a class="email" href="#emailpopup?deli_id=">info</a></p></td> </div> </td> </ItemTemplate> </asp:DataList> </div> <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [kurve] WHERE kurve_id = 1"></asp:SqlDataSource> <div id="ekstra_pris"> <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource3"> <ItemTemplate> <%#Eval("pris") %> kr. </ItemTemplate> </asp:Repeater> <asp:Label ID="Label_Vispris" runat="server" Text=""></asp:Label> <asp:Button ID="Button1" runat="server" Text="Opdater" OnClick="Button1_Click" /> </div>
protected void Button1_Click(object sender, EventArgs e) { int totalvaerdi = 0; List<ValgtDeli> valgteDeli = new List<ValgtDeli>(); //Her laver jeg en liste over valgte frugter. Det er et nyt objekt, som kan indeholde påde ID, Navn, Antal og Værdi foreach (DataListItem item in VisDeli.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { TextBox Textbox_antal = item.FindControl("TextBox_deli") as TextBox; int pris = 149; int prisVare = ; int enkeltFrugtAntal = int.Parse(Textbox_antal.Text); totalvaerdi = pris + enkeltFrugtAntal; } } if (totalvaerdi > 0) { Label_Vispris.Text = Convert.ToString(totalvaerdi); } }
CountOfProduct
kurve_id
3
CountOfProduct = 5
>PriceOfProduct
Price =10
kurve_id =3
PriceOfProduct = 10
TotalPricce
total price
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)