从中继器的输入传递值

时间:2018-09-02 21:48:44

标签: c# asp.net return-value repeater

我有一个中继器来列出产品。用户输入并批准它。

<asp:Repeater ID="rptItems" runat="server" OnItemCommand="rptItems_ItemCommand">
    <ItemTemplate>
        <input name="Amount" id="Amount" autofocus="autofocus" required="required" type="number" step=".01" max="<%#Eval("AMOUNT") %>" min="0.01" placeholder="Enter amount (Max: <%#Eval("AMOUNT") %> <%#Eval("UNIT") %>)" style="width:100%; padding:10px 5px 10px 0; font-size:12px; margin-bottom:10px; text-align:center;" />
        <asp:Button ID="Button1" CssClass="bt" runat="server" Text="ADD TO BASKET" Width="100%" CommandName="ButtonClick" CommandArgument='<%#Eval("ID")%>' UseSubmitBehavior="false" />
    </ItemTemplate>

protected void rptItems_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    if (e.CommandName == "ButtonClick")
    {

        int id = Convert.ToInt32(e.CommandArgument);

        string SQLOrdD = "INSERT INTO N_ORDERDETAIL (ClientID, ProductID, Amount) VALUES (@ClientID, @ProductID, @Amount);
        SqlCommand rsOrdD = new SqlCommand(SQLOrdD, bag.Bagla());


        decimal Amount = Convert.ToDecimal(Request.Form["Amount"]);



        rsOrdD.Parameters.AddWithValue("@ClientID", Session["ClientID"]);
        rsOrdD.Parameters.AddWithValue("@ProductID", PrID);
        rsOrdD.Parameters.AddWithValue("@Amount", Amount);

        bag.Bagla().Close();
    }
}

如何获取金额的值。 谢谢...

0 个答案:

没有答案