0

How to access or found "TextBox" control inside "ListView" Control ?

For example I want to use this.AddCommentTextbox.Text property in code-behind of this aspx page.

aspx page code:

 <asp:ListView ID="PostsListView" runat="server" DataSourceID="EntityDataSourcePosts">
   <ItemTemplate>
     <asp:TextBox Text="active" ID="AddCommentTextbox" runat="server"  TextMode="MultiLine" Height="100" Width="370"></asp:TextBox>
   </ItemTemplate>
 </asp:ListView> 
TheChampp
  • 1,337
  • 5
  • 24
  • 41

2 Answers2

0

Simply loop through items of the ListView and then either use FindControl("AddCommentTextbox") or loop through controls to find if a control is of type TextBox.

walther
  • 13,466
  • 5
  • 41
  • 67
0
TextBox commentTextBox = (TextBox)PostsListView.FindControl("AddCommentTextbox");
Ryan
  • 615
  • 8
  • 19