Click here to Skip to main content
15,889,863 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys,

I have a repeater where i have added one user control,
the user control contains some text boxes n i have assigned its properties also.

i want to use to those properties from repeater to save the text given in usercontrol.

aspx code:
 <table>
                                                        <tr>
                                                            <td style="width: 100px">
                                                                <asp:Label ID="Label2" runat="server" Text="No.Items" Font-Bold="true"></asp:Label>
                                                            </td>
                                                            <td>
                                                                <asp:TextBox ID="txtno" runat="server"></asp:TextBox>
                                                            </td>
                                                            <td>
                                                                <asp:Button ID="btnadd" runat="server" CssClass="btn btn-warning" Text="Add More"
                                                                    OnClick="btnadd_Click" />
                                                            </td>
                                                        </tr>
                                                    </table>

<asp:Repeater ID="Repeater1" runat="server" >
                                                        <HeaderTemplate>
                                                            <table class="table table-bordered table-hover">
                                                                <thead class="bg-dark lt">
                                                                    <tr>
                                                                        <th>
                                                                            S.No#
                                                                        </th>
                                                                        <th><table><tr>
                                                                        <th align="center" style="width: 300px">
                                                                            Item
                                                                        </th>
                                                                        <th align="center"  style="width: 405px">
                                                                            Description
                                                                        </th>
                                                                        <th align="center"  style="width: 350px">
                                                                            Quantity
                                                                        </th>
                                                                        <th align="center"  style="width: 300px">
                                                                            Remarks
                                                                        </th></tr></table></th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody>
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <tr>
                                                                <td>
                                                                    
                                                                        <%# Container.ItemIndex + 1 %>
                                                                    
                                                                </td>
                                                                <td>
                                                                    <uc1:pousercontrol ID="pousercontrol1"  runat="server" />
                                                                </td>
                                                            </tr>
                                                        </ItemTemplate>
                                                        <FooterTemplate>
                                                            </tbody> </table>
                                                        </FooterTemplate>
                                                    </asp:Repeater>


aspx.cs:
protected void btnadd_Click(object sender, EventArgs e)
        {
            int i = Convert.ToInt32(txtno.Text);
            Repeater1.DataSource = Enumerable.Range(0, i);
            Repeater1.DataBind();
            btnadd.Enabled = false;
        }


i tried this, save button code:

protected void btnSave_Click(object sender, EventArgs e)
        {
            foreach (RepeaterItem item in Repeater1.Items)
            {
                UserControl uc = (UserControl)item.FindControl("pousercontrol1");
                //unable to get the properties
            }
        }


plz help guys.

thankz
Posted
Updated 8-Apr-14 5:04am
v2
Comments
Charan_Kumar 8-Apr-14 4:54am    
had u tried...?
UserControl uc = (UserControl)e.item.FindControl("pousercontrol1");
abdul subhan mohammed 8-Apr-14 5:12am    
yes, but when i'm using (usercontrol)e. , it is not showing item property.
Mukund Thakker 8-Apr-14 5:30am    
Can you post your HTML and code.

1 solution

foreach (RepeaterItem item in rpt1.Items)
       {
           UserControl uc = (UserControl)item.FindControl("uc_textbox");

           TextBox tb = (TextBox)uc.FindControl("txt1");
           Response.Write(tb.Text);
       }
 
Share this answer
 
Comments
abdul subhan mohammed 8-Apr-14 11:14am    
sorry, its not working

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