2012-03-01 74 views
0

我在Asp.net 4.0中有一个ListView控件C# 我正在尝试使默认模式=编辑模式与文本框。所以我拿了Item Template(默认模板)并用TextBox替换了我的数据绑定标签。 它工作正常。除文本框外只适用于其他行。因此,一半的行是Page Load的文本框,一半的Roes仍然是标签。这里是我的代码:在默认编辑模式下创建一个ListView控件

 <ItemTemplate> 
     <tr style=""> 
      <td> 
      <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' /> 
      </td> 
      <td> 

        <asp:TextBox ID="DiscountPercentageTextBox" runat="server" 
        Text='<%# Bind("DiscountPercentage") %>' /> 
      </td> 
      <td> 

      <asp:TextBox ID="CashTextBox" runat="server" Text='<%# Bind("Cash") %>' /> 
      </td> 
     </tr> 
    </ItemTemplate> 
     <LayoutTemplate> 
    <table> 
     <thead> 
      <tr> 
       <th>Title </th> 
       <th>DiscountPercentage</th> 
       <th>Cash</th> 
      </tr> 
     </thead> 
     <tbody> 
      <asp:PlaceHolder runat="server" ID="itemPlaceholder" /> 
     </tbody> 
    </table> 
</LayoutTemplate> 

这里是结果:

enter image description here

你明白吗?每隔一行都是一个文本框。我需要所有行为文本框。我究竟做错了什么?

+0

人们仍然使用Webforms?! – Jack 2012-03-01 20:55:56

回答

0

呵呵,你有没有定义一个AlternatingItemTemplate? ListVIew没有智能将原始字段设置为标签....

尝试将ALternatingItemTemplate作为ItemTemplate,如果没有定义。

+0

是的!谢谢你做到了!绿色复选标记! – 2012-03-01 21:10:16

相关问题