c# 如何通过cell属性获取html控件 ?

<asp:Repeater>
 <ItemTemplate>
 <tr>
 <td>
 <asp:TextBox ID="TextBox1" cell="TextBoxCell" runat="server"></asp:TextBox>
 </td>
 </tr>
 </ItemTemplate>
 </asp:Repeater>

C# 后台 如何直接通过TextBox 的 cell 属性 获取 TextBox 控件的集合(取值用), 急


望采纳!!点击该回答右侧的“采纳”按钮即可采纳!!
在 C# 后台代码中,你可以使用 FindControl 方法来查找指定 ID 的控件,例如:

TextBox textBox = (TextBox)Repeater1.FindControl("TextBox1");

如果要获取所有 TextBox 控件的集合,你可以使用以下代码:

List textBoxList = new List();
foreach (Control control in Repeater1.Controls)
{
if (control is TextBox)
{
textBoxList.Add((TextBox)control);
}
}

注意,在上面的代码中,Repeater1 是 asp:Repeater 控件的 ID。