Question

I've got a LinkButton set up in the ItemTemplate of a ListView. It displays fine, but it's not doing anything when clicked. It's supposed to be a simple Edit button, but it's driving my crazy. Here's the button:

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

and here's the 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

What might cause the link to do nothing?

Here's the whole list view if that helps:

<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>
Was it helpful?

Solution

My bad - I had validator elsewhere on the form, so the link appeared to be doing nothing because it was tripping the validation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top