2013-02-16 99 views
0

当我在ListView控件中创建InsertItemTemplate时,它不会出现。为什么?这个代码中的问题在哪里?当我运行它时,我看不到使用TextBox控件的“输入文本”。来自ListView的InsertItemTemplate不会出现

<asp:ListView ID="ChatListView" runat="server" DataSourceID="EntityDataSourceUserPosts" OnItemDataBound="ChatListView_ItemDataBound"> 
    <ItemTemplate> 
      <div class="postContent"> 
       <%# Eval("PostComment") %> 
      </div> 
     </div> 
    </ItemTemplate> 
    <InsertItemTemplate> 
     <asp:Label ID="Label2" runat="server" Text="ENTER TEXT"></asp:Label> 
     <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
    </InsertItemTemplate> 

</asp:ListView> 

回答

1

你设置InsertItemPosition象下面这样:

protected void btn_Click(object sender, EventArgs e) 
    { 
     ChatListView.InsertItemPosition = InsertItemPosition.FirstItem; 
    } 
+0

我忘了做。所以每当我想要使用InsertItemTemplate时,我都必须将InsertItemTemplate的位置设置正确? – TheChampp 2013-02-16 09:56:41

+0

是的..很高兴能工作 – MaxDataSol 2013-02-16 09:57:21

+0

还有一个问题要问你。 “ListViewItemType.InsertItem”方法返回InsertItemTemplate或某种其他项目? – TheChampp 2013-02-16 10:00:03