[ad_1]
如何在其他中继器内部的中继器中查找文本框控制值并更新数据该中继器生成部门和其他中继器以生成员工及其薪水,当我按保存板条时,它可以从文本框(薪水)中获取值并更新数据在数据库中
此代码用于生成数据并填充中继器
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
和这个html代码
网络平台
<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" />
解决方案1
像下面这样的东西。 您需要循环遍历这些项目并找到控件 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
解决方案2
<项目模板>
protected void RPL_ItemCommand(对象源, RepeaterCommandEventArgs e)
{
TextBox TxtQty = (TextBox)e.Item.FindControl(“TxtQty”);
HiddenField HidPro = (HiddenField)e.Item.FindControl(“HidPro”);
会议[“PLQty”] = HidPro.Value;
会议[“PLId”] = TxtQty.Text;
}
[ad_2]
コメント