开发者

How to get dropdownlist value within a repeater, to be inserted in a method?

I've got this repeater on My .aspx page :

<asp:Repeater ID="RptCart" runat="server" OnItemDataBound="RptCart_ItemDataBound"
            OnItemCommand="RptCart_ItemCommand">
            <HeaderTemplate>
                <table class="style1" style="border-style: solid; border-width: 1px">
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td colspan="2">
                        &nbsp;
                    </td>
                    <td valign="top">
                        NUMBER OF SHIRTS
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td valign="top">
                        EXTRAS
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td valign="top">
                        DISCOUNTS
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td valign="top">
                        SUBTOTAL
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        <%# Container.ItemIndex + 1 %>
                    </td>
                    <td style="text-align: center">
                        <asp:Image ID="imgFabric" runat="server" Width="55px" Height="55px" />
                    </td>
                    <td>
                        <br />
                        Quantity<br />
                        <asp:DropDownList ID="ddlQuantity" runat="server" AutoPostBack="true">
                            <asp:ListItem Value="1">1</asp:ListItem>
                            <asp:ListItem Value="2">2</asp:ListItem>
                            <asp:ListItem Value="3">3</asp:ListItem>
                            <asp:ListItem Value="4">4</asp:ListItem>
                            <asp:ListItem Value="5">5</asp:ListItem>
                            <asp:ListItem Value="6">6</asp:ListItem>
         开发者_开发知识库                   <asp:ListItem Value="7">7</asp:ListItem>
                            <asp:ListItem Value="8">8</asp:ListItem>
                            <asp:ListItem Value="9">9</asp:ListItem>
                            <asp:ListItem Value="10">10</asp:ListItem>
                        </asp:DropDownList>
                        <br />
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td valign="top">
                        Supplement for monogram
                    </td>
                    <td valign="top">
                        0,00
                    </td>
                    <td valign="top">
                        Discount for short sleeves
                    </td>
                    <td valign="top">
                        0,00
                    </td>
                    <td valign="top">
                        Basic price<br />
                        Extras<br />
                        Discounts
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td valign="top">
                        0,00<br />
                        0,00<br />
                        0,00
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td style="text-align: center">
                        &nbsp;
                    </td>
                    <td>
                        <asp:LinkButton ID="lnkCancel" runat="server" Text="Cancel" CommandName="Cancel"></asp:LinkButton>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <b>Total of extras</b>
                    </td>
                    <td>
                        <b>0,00</b>
                    </td>
                    <td>
                        <b>Total discount </b>
                    </td>
                    <td>
                        <b>0,00</b>
                    </td>
                    <td>
                        <b>Total per shirt </b>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <b>0,00</b>
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table></FooterTemplate>
        </asp:Repeater>

The question is, how can i get the Dropdownlist value from the repeater ? And the dropdownlist value is executed within a method(let's say : "private void InsertDatabase()")

This code purpose is to insert the Dropdownlist value to the database, and it's fired when the Button is clicked (I put the ""private void InsertDatabase()" on the "Click" event of the button.

Thanks in advance.


You can get drop down list value by using below mentioned code

foreach (RepeaterItem rptItem in RepeaterName.Rows)
{
         DropDownList ddlQuantity = (DropDownList)gvr.FindControl("ddlQuantity");
}

Through this way you can find drop down list and can get it's value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜