Click here to Skip to main content
15,915,093 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
if (detail_repeat.Items.Count > 0)
{
    for (int count = 0; count < detail_repeat.Items.Count; count++)
    {
        // RadioButton rd1 = (RadioButton)Repeater1.Items[count].FindControl("rbAccept");
        TextBox quantitytext = (TextBox)detail_repeat.Items[count].FindControl("txt_quan");
        // TextBox quantitytext = ri.FindControl("txt_quan") as TextBox;
        //Label productprice = detail_repeat.FindControl("lbl_price") as Label;
        Label productprice = (Label)detail_repeat.Items[count].FindControl("lbl_price");

        quantityText = quantitytext.Text;
        productpriceText = productprice.Text;
    }
}

aspx code
XML
<asp:Repeater ID="detail_repeat" runat="server" OnItemCommand="detail_repeat_ItemCommand">

    <ItemTemplate>

        <div>
            <div>
                <div class="detail_image">
                    <img src='<%#getpath()%><%# DataBinder.Eval(Container.DataItem, "Image")%>' />
                </div>
                <div id="detail_details">
                    <div class="detail_content">
                        <div class="detail_label">
                            <asp:Label runat="server" Text="PRODUCT NAME"></asp:Label>
                        </div>
                        <div class="detail_value">
                            <asp:Label ID="lbl_productname" runat="server" Text='<%# Eval("product_name") %>'></asp:Label><br />
                        </div>
                    </div>
                    <div class="detail_content">
                        <div class="detail_label">
                            <asp:Label runat="server" Text="PRODUCT QUANTITY"></asp:Label>
                            <asp:Label ID="lbl_quanstar" runat="server" Text="" Style="color: red">*</asp:Label>
                        </div>
                        <div class="detail_value">

                            <asp:TextBox ID="txt_quan" runat="server" Width="20px" ReadOnly="false" Text=""></asp:TextBox><br />
<asp:RequiredFieldValidator ID="Rreqval_quantity" runat="server" ValidationGroup="detail" ControlToValidate="txt_quan" ErrorMessage="Quantity is mandatory"></asp:RequiredFieldValidator>
                        </div>
                    </div>
                    <div class="detail_content">
                        <div class="detail_label">
                            <asp:Label runat="server" Text="PRODUCT PRICE"></asp:Label>
                        </div>
                        <div class="detail_value">
                            <asp:Label ID="lbl_price" runat="server" Text='<%# Eval("price")%>'></asp:Label><br />
                        </div>
                    </div>
                    <div class="detail_content">
                        <div class="detail_label">
                            <asp:Label runat="server" Text="PRODUCT DESCRIPTION"></asp:Label>
                        </div>
                        <div class="detail_value">
                            <asp:Label ID="lbl_description" runat="server" Text='<%# Eval("descrip")%>'></asp:Label><br />
                        </div>
                    </div>
                </div>
            </div>
    </ItemTemplate>
</asp:Repeater>

getting text box value null when using repeater
Posted
Updated 21-Oct-15 20:32pm
v2
Comments
Sreekanth Mothukuru 23-Oct-15 4:09am    
It seems like you have not assigned value to "txt_quan" text box in your repeater!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900