views:

125

answers:

2

I have the following DataList:

<asp:DataList ID="values" Visible="false" runat="server" DataKeyField="Id">
<ItemTemplate>
    <div id="row" style="height: 25px; vertical-align: top">
     <div id="left" style="visibility: hidden; width: 25px">
      <%# DataBinder.Eval(Container.DataItem, "Id") %>
     </div>
     <div id="middle" style="width: 400px">
      <%# DataBinder.Eval(Container.DataItem, "Name") %>
     </div>
     <div id="right" style="width: 200px">
      <asp:TextBox ID="txtValue" CssClass="required number" runat="server">
      <%# DataBinder.Eval(Container.DataItem, "Value") %>
      </asp:TextBox>
     </div>
    </div>
</ItemTemplate>
</asp:DataList>

I want to bind textbox initial value, but Intellisense says I can't write this block to bind Text's property for TextBox.

Which alternative do I have, without considering codebehind?

+2  A: 

Bind to the Text property

<asp:TextBox ID="txtValue" CssClass="required number" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Value") %>'>
                </asp:TextBox>
CSharpAtl
It doesn't work.
Victor Rodrigues
It works only when I use " instead of ' . amazing... thanks!
Victor Rodrigues
What's the error message?
rball
+1  A: 

Try:

<asp:TextBox ID="txtValue" CssClass="required number" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Value") %>'></asp:TextBox>
rball