[ad_1]
bagaimana menemukan nilai kontrol kotak teks di repeater di dalam repeater lain dan memperbarui data repeater ini menghasilkan departemen dan repeater lain untuk menghasilkan Karyawan dengan GAJI mereka dan ketika saya menekan simpan reng itu dapat mengambil nilai dari kotak teks (GAJI) dan memperbarui data di DB
kode ini untuk menghasilkan data dan mengisi repeater
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
dan kode html ini
<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" />
Solusi 1
Sesuatu seperti di bawah ini. Anda perlu mengulang item dan menemukan kontrolnya Salary
.
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
Solusi 2
dilindungi kekosongan RPL_ItemCommand(sumber objek, RepeaterCommandEventArgs e)
{
Kotak Teks TxtQty = (Kotak Teks)e.Item.FindControl(“TxtQty”);
HiddenField HidPro = (HiddenField)e.Item.FindControl(“HidPro”);
Sidang[“PLQty”] = HidPro.Nilai;
Sidang[“PLId”] = TxtQty.Teks;
}
[ad_2]
コメント