Costa
Costa

Reputation: 4095

ListView InsertItemTemplate Does not work

I can't get <%# Eval("ID") %> work, although it works outside of the InserItemTemplate. What is worng?

<InsertItemTemplate>
        <tr style="">
            <td>
                <asp:Button ID="btnInsert" runat="server" CommandName="InsertPhone" CommandArgument='<%# Eval("ID") %>' Text="InsertPhone" />

            </td>             
            <td style="width:50px">
                  <asp:DropDownList runat="server" ID="ddlPhoneType" DataSourceID='ObjectDataSourcePhoneTypes'
                    DataTextField="Name_ar" DataValueField="ID" />

            </td>
            <td style="width:100px">
                <asp:TextBox ID="PhoneNumberLabel" runat="server" Text='' />
            </td>
        </tr>
    </InsertItemTemplate>

Thanks

Upvotes: 1

Views: 730

Answers (1)

Brian Mains
Brian Mains

Reputation: 50728

Insert template isn't data bound so you can't use Eval there... Eval works in the context of a data bound row, but insert row is not data bound, so there's no data source for it. Programmably set the value in the field if you need to establish some value for a control.

Upvotes: 3

Related Questions