I have a Repeater displaying rows from an SQL Server database.

I have an Edit and Delete button appearing in each row, but I can't successfully write code behind these buttons.

Here is the code to display the repeater:

<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
                        <ItemTemplate>
                            <div>
                                <table>                                    
                                    <tr><th><%#Eval("Event_Title")%></th><td><asp:Button ID="LinkButton1" runat="server" CommandName="Edit" Text="Edittttt"></asp:Button></td><td><button>Delete</button></td></tr>
                                    <tr><td>Event Group ID</td><td><%#Eval("Event_Group_Id") %></td></tr>
                                    <tr><td>Event Type</td><td><%#Eval("Event_Type")  %></td></tr>
                                    <tr><td>Event ID</td><td><%#Eval("Event_Id")  %></td></tr>
                                    <br />
                                </table>
                            </div>
                        </ItemTemplate>
                    </asp:Repeater>

And here is the UI.

I have tried to use the below code to see if the Edit button is working:

  protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    switch (e.CommandName)
    {
        case "Edit":
            Response.Write("Edit button clicked");
            break;

        default: break;
    }
}

But I am getting this error message:

Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Can anyone advise me as to where I go from here please?

Related posts

Recent Viewed