Why can't I bind inside asp: text property of Textbox?

I have the following list of data:

<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 the initial value of the text field, but Intellisense says that I cannot write this block to bind the Text property for the TextBox.

What alternative do I have, apart from codebehind?

+3
source share
2 answers

Binding to the Text property

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

Try:

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

Source: https://habr.com/ru/post/1718306/


All Articles