Domanda

Ho un LinkButton impostato in ItemTemplate di un ListView. Viene visualizzato correttamente, ma non fa nulla quando si fa clic. Dovrebbe essere un semplice pulsante Modifica, ma mi sta facendo impazzire. Ecco il pulsante:

<asp:LinkButton ID="EditLinkButton" runat="server" CommandName="Edit" Text="Edit" />

ed ecco il code-behind:

Protected Sub MyListView_ItemEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewEditEventArgs) Handles MyListView.ItemEditing
    MyListView.EditIndex = e.NewEditIndex
    GetListViewData()
End Sub

Cosa potrebbe impedire al link di non fare nulla?

Ecco l'intera vista dell'elenco se ciò aiuta:

<asp:ListView ID="MyListView" runat="server" DataKeyNames="my_id">
    <LayoutTemplate>
        <table cellpadding="3">
            <tr class="tableHeader">
                <th>
                    Name
                </th>
                <th>
                </th>
            </tr>
            <asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
        </table>
    </LayoutTemplate>
    <ItemTemplate>
        <tr class="tableRow">
            <td>
                <%#Eval("my_name")%>
            </td>
            <td>
                <asp:LinkButton ID="EditLinkButton" runat="server" CommandName="Edit" Text="Edit" />
                |
                <asp:LinkButton ID="DeleteLinkButton" runat="server" CommandName="Delete" Text="Delete" />
            </td>
        </tr>
    </ItemTemplate>
    <EditItemTemplate>
        <tr class="tableRow">
            <td>
                <asp:TextBox ID="NameTextBox" runat="server" Columns="30" />
            </td>
            <td>
                <asp:LinkButton ID="CancelLinkButton" runat="server" CommandName="Cancel" Text="Cancel" />
                |
                <asp:LinkButton ID="DeleteLinkButton2" runat="server" CommandName="Delete" Text="Delete" />
            </td>
        </tr>
    </EditItemTemplate>
</asp:ListView>
È stato utile?

Soluzione

Mio male: avevo un validatore altrove nel modulo, quindi il link sembrava non fare nulla perché stava facendo scattare la convalida.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top