如何在中继器中创建事件下拉列表(选定的已更改事件)

how to create event dropdownlist in repeater ( selected changed event)

我想处理转发器中到达项目的下拉列表事件 (selectedindexchanged)。

我在转发器中有每一行:(文本框、文本框、下拉列表)

根据下拉列表的值,我想隐藏和显示另外两个文本框

我该怎么做?

 <asp:Repeater runat="server" ID="rep" >
        <ItemTemplate>
          <asp:DropDownList ID="drp" runat ="server" OnSelectedIndexChanged="drp_SelectedIndexChanged" AutoPostBack="true">
                <asp:ListItem Text ="aa"></asp:ListItem>
                <asp:ListItem Text="bb"></asp:ListItem>
            </asp:DropDownList>
            <asp:TextBox ID="txtA" runat="server"></asp:TextBox>
        </ItemTemplate>
       </asp:Repeater>

在代码隐藏中:

VB.NET :

Protected  Sub drp_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim drp As DropDownList = CType(sender, DropDownList)
Dim itm As RepeaterItem = CType(drp.Parent, RepeaterItem)

Dim txtA As TextBox = CType(itm.FindControl("txtA"), TextBox)
 If txtA <> Nothing And drp.SelectedValue ="aa" Then
      'txtA.Text = "AAA";
    txtA.Visible = False
 End If  End Sub

或 C#:

 protected void drp_SelectedIndexChanged(object sender, EventArgs e)
{
    DropDownList drp = (DropDownList)sender;
    RepeaterItem itm = (RepeaterItem)drp.Parent;

    TextBox txtA = (TextBox)itm.FindControl("txtA");
     if (txtA != null && drp.SelectedValue =="aa")
    {
          //txtA.Text = "AAA";
        txtA.Visible = false;
    }

}