Advertisement

05.03.2008 at 06:47AM PDT, ID: 23373803
[x]
Attachment Details

Getting the value selected by a dropdown list inside a repeater which uses command argument on button click

Asked by bluefezteam in Microsoft Visual Basic.Net, Web Languages/Standards, Programming for ASP.NET

Tags: VB.NET

Hi,

I have a repeater control which is populated with a dataset to display a list of products. I have a button within each itemtemplate which passes the primary key from that table as the command argument. I need to be able to pass in the quantity value selected from the dropdown list corresponding to that item.

HTML:

<asp:Repeater ID="rptProducts" runat="server">
    <ItemTemplate>
        <%#Eval("name")%><br />
        <%#Eval("image")%><br />
        <%#Eval("Price")%><br />
        <asp:DropDownList ID="ddlQty" runat="server">
            <asp:ListItem Value="1" Text="1"></asp:ListItem>
            <asp:ListItem Value="2" Text="2"></asp:ListItem>
            <asp:ListItem Value="3" Text="3"></asp:ListItem>
            <asp:ListItem Value="4" Text="4"></asp:ListItem>
            <asp:ListItem Value="5" Text="5"></asp:ListItem>
            <asp:ListItem Value="6" Text="6"></asp:ListItem>
            <asp:ListItem Value="7" Text="7"></asp:ListItem>
            <asp:ListItem Value="8" Text="8"></asp:ListItem>
            <asp:ListItem Value="9" Text="9"></asp:ListItem>
            <asp:ListItem Value="10" Text="10"></asp:ListItem>
        </asp:DropDownList>
        <asp:Button ID="btnAddBskt" runat="server" CommandName="Add" CommandArgument='<%#Eval("PID") %>' Text="add to basket" />
        <hr />
    </ItemTemplate>
</asp:Repeater>

VB

    Protected Sub rptProducts_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rptProducts.ItemCommand
        Select Case e.CommandName
            Case "Add"
                Dim PID As Integer
                Dim Qty As Integer
                PID = e.CommandArgument
                'Qty = [???????]
                functions.addToBasket(Qty, PID, 1, 1.99)
        End Select
    End Sub


Thanks in advance,
RobStart Free Trial
[+][-]05.03.2008 at 07:52AM PDT, ID: 21492538

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, Web Languages/Standards, Programming for ASP.NET
Tags: VB.NET
Sign Up Now!
Solution Provided By: DarkoLord
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628