Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何访问asp repeater控件内的控件_Asp.net - Fatal编程技术网

Asp.net 如何访问asp repeater控件内的控件

Asp.net 如何访问asp repeater控件内的控件,asp.net,Asp.net,我有一个表单,允许用户更新他们的个人资料和联系信息。我在div标记中使用asp:repeater控件创建了此表单。我在repeater控件中有4个div标记,其中包含其他控件,如文本框和下拉列表。我只想知道,如何访问中继器控件内的控件。我给出了代码: <tr> <td class="directorytdWidth"> Gender: </td> <td class="directoryTdPadding"> <asp:TextBox ID=

我有一个表单,允许用户更新他们的个人资料和联系信息。我在div标记中使用asp:repeater控件创建了此表单。我在repeater控件中有4个div标记,其中包含其他控件,如文本框和下拉列表。我只想知道,如何访问中继器控件内的控件。我给出了代码:

<tr>
<td class="directorytdWidth">
Gender:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtGender" runat="server"    Width="100px" Text='<%#Eval("gender")%>'></asp:TextBox>
<asp:RadioButtonList ID="radioGender" runat="server" RepeatColumns="2" Visible="false">
<asp:ListItem Text="Male" Value="M"></asp:ListItem>
<asp:ListItem Text="Female" Value="F">  </asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Address:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtAdd" runat="server" Width="200px"     Text='<%#Eval("candiAddress")%>'
TextMode="MultiLine" Height="75px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Country:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtCountry" runat="server" Width="150px" Text='<%#Eval("countryName")%>'></asp:TextBox>
<asp:DropDownList ID="drpCountry" runat="server"    SelectedValue='<%#Eval("countryName")%>' Width="150px" Height="24px" Visible="false"
AutoPostBack="true"   OnSelectedIndexChanged="drpCountry_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
State:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtState" runat="server"    Width="150px" Text='<%#Eval("stateName")%>'></asp:TextBox>
<asp:DropDownList ID="drpState" runat="server" SelectedeValue='<%#Eval("stateName")%>' Width="150px" Visible="false" Height="24px"
AutoPostBack="true" OnSelectedIndexChanged="drpState_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
City:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtCity" runat="server" Width="150px"     Text='<%#Eval("cityName")%>'></asp:TextBox>
<asp:DropDownList ID="drpCity" runat="server" Width="150px" Height="24px" Visible="false"
AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Postal Code:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtPostalCode" runat="server"    Width="150px" Text='<%#Eval("pincode")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Landline:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtLandline" runat="server" Width="150px" Text='<%#Eval("landline")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Mobile Number:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtMobile" runat="server" Width="150px" Text='<%#Eval("mobile")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Date of Birth:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtDob" runat="server" Width="150px" Text='<%#Eval("dob")%>'></asp:TextBox>
<asp:DropDownList ID="drpYear" runat="server" Visible="false" Height="24px" Width="80px"
AutoPostBack="true">
</asp:DropDownList>
&nbsp;&nbsp;
<asp:DropDownList ID="drpMonth" runat="server"    Height="24px" Width="80px" OnSelectedIndexChanged="drpMonth_SelectedIndexChanged"
AutoPostBack="true" Visible="false">
<asp:ListItem Value="1" Selected="True">January</asp:ListItem>
<asp:ListItem Value="2">February</asp:ListItem>
<asp:ListItem Value="3">March</asp:ListItem>
<asp:ListItem Value="4">April</asp:ListItem>
<asp:ListItem Value="5">May</asp:ListItem>
<asp:ListItem Value="6">June</asp:ListItem>
<asp:ListItem Value="7">July</asp:ListItem>
<asp:ListItem Value="8">August</asp:ListItem>
<asp:ListItem Value="9">September</asp:ListItem>
<asp:ListItem Value="10">October</asp:ListItem>
<asp:ListItem Value="11">November</asp:ListItem>
<asp:ListItem Value="12">December</asp:ListItem>
</asp:DropDownList>
&nbsp;&nbsp;
<asp:DropDownList ID="drpDate" runat="server"    Height="24px" Width="50px" Visible="false"
AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Email Address:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtEmail" runat="server" Width="150px" Text='<%#Eval("altEmail")%>'></asp:TextBox>
</td>
</tr>

性别:
地址:
国家:
声明:
城市:
邮政编码:
固定电话:
手机号码:
出生日期:
一月
二月
前进
四月
也许
六月
七月
八月
九月
十月
十一月
十二月
电邮地址:
在本例中,我将下拉选择索引更改事件,那么如何触发此事件呢
我还想定义可以在下拉事件中访问的函数。因为当我定义函数时,我无法在中继器控件中获得控件。因此,请为我提供任何解决方案。提前感谢….

不确定您要访问哪些控件,但是

1) 让他们运行并给他们ID

2) 为
itemscreated
ItemDataBound
事件向中继器添加事件处理程序

3) 访问控制如下:

    void R1_ItemCreated(Object Sender, RepeaterItemEventArgs e) {
          var label = (Label)e.Item.FindControl("YourItemId")  
    }

一旦下拉事件位于repeater控件中,您就无法访问它们。您可以使用中继器的
ItemCommand
事件中的
CommandName
commandargument
对按钮执行操作


不过,您可以采取变通办法。从中继器中取出下拉列表,生成其
SelectedIndexChanged
事件和
AutoPostback=“true”
。然后放回中继器。现在,在代码隐藏事件中,您可以执行您的操作。我曾经这样做过,但这不是一个好方法。

发布一些相关的代码会给你一个答案。