Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to find text-box control value in repeater in inside other repeater and update data this repeater generate department and other repeater to generate Employees with their SALARY and when i press save batten it can take value from text-box( SALARY) and update data in DB
this code for generate the data and fill repeater
VB
Private Sub BindData()
      Try
          dt = cls.rtv_All_Dep
          rptCustomRepeater.DataSource = dt
          rptCustomRepeater.DataBind()

      Catch
      End Try
  End Sub
  Protected Sub CustomInfoRepeater_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptCustomRepeater.ItemDataBound
      If e.Item.ItemType = ListItemType.Item Then
          Try

              Dim LabID As Label = TryCast(e.Item.FindControl("LabID"), Label)
              Dim lblManID As Label = TryCast(e.Item.FindControl("lblManID"), Label)
              Dim Repeater1 As Repeater = TryCast(e.Item.FindControl("Repeater1"), Repeater)
              Dim depID As Integer = LabID.Text
              dt = cls.rtv_All_Emp(depID)
              Repeater1.DataSource = dt
              Repeater1.DataBind()



          Catch
          End Try
      End If
  End Sub

and this html code
ASP.NET
<asp:Repeater ID="rptCustomRepeater" runat="server">
            <HeaderTemplate>
                
            </HeaderTemplate>
            <ItemTemplate>
                <table id="rptCustom">
                    <tr class="rptHeader">
                        <th>DEPARTMENT_ID</th>
                        <th>DEPARTMENT_NAME</th>
                        <th>MANAGER_ID</th>
                    </tr>
                <tr class="rptDataRows">
                    <td><asp:Label ID="LabID" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "DEPARTMENT_ID")%>'></asp:Label> </td>
                    <td><%#DataBinder.Eval(Container.DataItem, "DEPARTMENT_NAME")%> </td>
                    <td><asp:Label ID="lblManID" runat="server"  Visible="false" Text='<%#DataBinder.Eval(Container.DataItem,"MANAGER_ID")%>'></asp:Label></td>
                         <td><asp:Label ID="lblManName" runat="server" Text=""></asp:Label> </td>
            </tr>
                </table>
                
                       
                <asp:Repeater ID="Repeater1" runat="server">

                    <HeaderTemplate>  <table id="rptEmp">
                    <tr class="rptHeader">
                        <th>EmpID</th>
                        <th>Emp NAME</th>
                        <th>SALARY</th>
                    </tr></HeaderTemplate>
                    <ItemTemplate>

                       
                <tr class="rptDataRows">
                    <td><asp:Label ID="LabID" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "EMPLOYEE_ID")%>'></asp:Label> </td>
                    <td>
                         <asp:Label ID="lblEmpFName" runat="server" Text= '<%#DataBinder.Eval(Container.DataItem, "FIRST_NAME")%>' ></asp:Label>  <asp:Label ID="lblEmpSName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "LAST_NAME")%>'></asp:Label></td>
                         <td>
                             <asp:TextBox ID="txtSALARY"  runat="server"  Text='<%#DataBinder.Eval(Container.DataItem, "SALARY")%>'></asp:TextBox>
                         </td>
            </tr>
                
                


                    </ItemTemplate>
                    <FooterTemplate></table>
                        -----------------------------------------------------------------------------------------------------------------
                        <br />
                        -----------------------------------------------------------------------------------------------------------------

                    </FooterTemplate>

                </asp:Repeater>



              
            </ItemTemplate>
            <FooterTemplate>
                
            </FooterTemplate>

        </asp:Repeater>
        <asp:Button ID="Button1" runat="server" Text="Button" />
Posted
Comments
Kornfeld Eliyahu Peter 18-Oct-15 5:00am    
Read this: http://www.codeproject.com/Articles/775111/Understanding-ASP-NET-Templates
jihad86 18-Oct-15 6:40am    
may you help me ??
jihad86 18-Oct-15 6:39am    
ok, but i try to find text box inside child repeater how can i get and work withe it .
See my answer.
jihad86 18-Oct-15 7:48am    
thanks mr Tadit Dash it is work fine

1 solution

Something like below. You need to loop through the items and find the control for Salary.
VB
Dim Repeater1 As Repeater = TryCast(e.Item.FindControl("Repeater1"), Repeater)

For Each item In Repeater1.Items

   dim txtSalary As TextBox = TryCast(item.FindControl("txtSALARY"), TextBox)

   ' Do whatever you want to do with this textbox value.

Next
 
Share this answer
 

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