Using Bind in a TextBox Displays Related Data Outside of a TextBox Control

I have ListView(in the update panel) associated with ObjectDataSource(connected to an NHibernate object), and in EditItemTemplateI use

Text='<%# Bind("HideLocation")%>' 

to bind to the string property of the object.

When I click the "Edit" button (twice, I have another problem) and look at the code in Chrome, the output looks like this:

<div class="InputLine InputLineLevel2">
    <div class="InputLabel">Hide Location:</div>
    <div class="InputControl">
     "
                        In locker 2317"
        <input 
            name="ctl00$MainContentPlaceholder$ItemDetailsListView$ctrl0$txtItemHideLocation"
            type="text"
            maxlength="128"
            id="ctl00_MainContentPlaceholder_ItemDetailsListView_ctrl0_txtItemHideLocation"
            style="width:300px;">
    </div>
</div>

The .aspx code is as follows:

 <asp:UpdatePanel ID="ItemDetailsUpdatePanel" UpdateMode="Always" runat="server">
    <asp:ListView ID="ItemDetailsListView" runat="server" ...>
         <EditItemTemplate>
             <fieldset class="FieldsetLevel2">
             <legend>Edit Item: <%# Eval("SearchItem.SearchItemName") %></legend>
                 <div class="InputLine InputLineLevel2">
                     <div class="InputLabel">Hide Location:</div>
                     <div class="InputControl">
                         <asp:TextBox ID="txtItemHideLocation" Width="300px"
                             Text='<%# Bind("HideLocation")%>'
                             runat="server"></asp:TextBox>
                     </div>
                 </div>
... a bunch of other controls & end tags

Any ideas why the value of the associated data (in this case: In the 2317 cabinet) appears outside the text field instead of the data content?

+3
source share
1 answer

, , . , .

, . , , TextBox. -, , , datasource. ListView, . ISet, .

, , (-, , ), xDataSource, , ListView. , , , DataBound.

-, , . , EditItemIndex. ( , PreRender), , ListView. ( ) , ( , , ).

databind EditIndex, , TextBox .

0

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


All Articles