2013-02-24 84 views
2

如何访问“ListView”控件中的“TextBox”控件?在ListView控件中访问TextBox控件

例如,我想在代码隐藏中使用this.AddCommentTextbox.Text属性。

ASPX代码:

<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> 

回答

3

你可以尝试这样的事:

TextBox tmpControl = (TextBox)PostsListView.FindControl("AddCommentTextbox"); 

那么你可以做一些与tmpControl.text

希望有所帮助。