repeater item command in asp.net

Koray Durudogan

i am working with asp.net and i have a repeater.I want to take a respond from one of the items, which has been displayed by repeater.Here is my code:

<asp:Repeater ID="Repeatercart" runat="server" OnItemCommand ="RepeaterDeleteitemcommand" >
<ItemTemplate>                     
    <table> 
    <tr>
        <td><img id="Image1" src="PerfumeImages/<%#Eval("ProductImage") %>" width="90" /></td>
    </tr>                               
    <tr>
        <td><%#Eval("ProductName") %> x<%#Eval("Quantity") %></td>
    </tr>
    <tr>
        <td> <%#Eval("ProductGender") %></td>
    </tr>
    <tr>
        <td> <%#Eval("ProductSize") %> ml</td>
    </tr>                               
    <tr>
        <td><a class="buy-btn"><asp:Button ID="Button1" CommandName="Click" Text="Remove from cart" runat="server" CommandArgument='<%# Eval("ProductId") %>' /></a></td>
    </tr>
    </table>            
</ItemTemplate>
</asp:Repeater>   

and this is my codebehind:

protected void RepeaterDeleteitemcommand(object source, RepeaterCommandEventArgs e)
{
    switch (e.CommandName)
    {
        case "Click":
               Label1.Text = "ok !";
               break;
    }
}  

When i run this code, i get an error like: 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.Thanks for the help

Koray Durudogan

I solved the problem and wanted to write here, so i can help anyone with the same problem.Adding an "if (!IsPostBack)" under the pageload is solving the problem.Thanks for the all help.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ASP.NET Converting repeater item to the textbox

From Dev

jQuery is not finding Asp.net repeater alternating item

From Dev

ASP.NET Repeater Item add divider after each row

From Dev

NavigateUrl on Repeater ASP.net

From Dev

NavigateUrl on Repeater ASP.net

From Dev

Is there an ASP.NET databindable control (like Repeater), which only expects a single item?

From Dev

Hiding the first item of an ASP.NET Repeater causes error: not a valid identifier

From Dev

ASP.NET repeater only renders the first item in my XML data source

From Dev

Is there an ASP.NET databindable control (like Repeater), which only expects a single item?

From Dev

Delete an item from an asp:Repeater using jQuery

From Dev

ASP.NET Repeater - Eval() for bool?

From Dev

Convert Bootstrap Carousel to ASP.Net Repeater

From Dev

ASP .NET Using a Repeater inside of UpdatePanel with UpdateProgress

From Dev

asp.net repeater for each row

From Dev

to disable a label of repeater on some condition in asp .net

From Dev

Using Bootstrap tabs with ASP NET repeater

From Dev

asp.net repeater use template in javascript

From Dev

To bind images in repeater using asp.net

From Dev

asp.net repeater merge columns dynamically

From Dev

Fix header row in repeater in ASP.NET

From Dev

Repeater asp.net tag not working

From Dev

asp.net repeater merge columns dynamically

From Dev

Convert Bootstrap Carousel to ASP.Net Repeater

From Dev

Conditional statement for Repeater Controll in ASP.NET

From Dev

Fix header row in repeater in ASP.NET

From Dev

trying Image Button in repeater Asp.net

From Dev

asp net dropdown selectedvalue/selectedindex not updating in repeater

From Dev

ASP.Net - Issues with Repeater / DataBinding

From Dev

Repeater in asp.net from DB with DropDownList

Related Related

  1. 1

    ASP.NET Converting repeater item to the textbox

  2. 2

    jQuery is not finding Asp.net repeater alternating item

  3. 3

    ASP.NET Repeater Item add divider after each row

  4. 4

    NavigateUrl on Repeater ASP.net

  5. 5

    NavigateUrl on Repeater ASP.net

  6. 6

    Is there an ASP.NET databindable control (like Repeater), which only expects a single item?

  7. 7

    Hiding the first item of an ASP.NET Repeater causes error: not a valid identifier

  8. 8

    ASP.NET repeater only renders the first item in my XML data source

  9. 9

    Is there an ASP.NET databindable control (like Repeater), which only expects a single item?

  10. 10

    Delete an item from an asp:Repeater using jQuery

  11. 11

    ASP.NET Repeater - Eval() for bool?

  12. 12

    Convert Bootstrap Carousel to ASP.Net Repeater

  13. 13

    ASP .NET Using a Repeater inside of UpdatePanel with UpdateProgress

  14. 14

    asp.net repeater for each row

  15. 15

    to disable a label of repeater on some condition in asp .net

  16. 16

    Using Bootstrap tabs with ASP NET repeater

  17. 17

    asp.net repeater use template in javascript

  18. 18

    To bind images in repeater using asp.net

  19. 19

    asp.net repeater merge columns dynamically

  20. 20

    Fix header row in repeater in ASP.NET

  21. 21

    Repeater asp.net tag not working

  22. 22

    asp.net repeater merge columns dynamically

  23. 23

    Convert Bootstrap Carousel to ASP.Net Repeater

  24. 24

    Conditional statement for Repeater Controll in ASP.NET

  25. 25

    Fix header row in repeater in ASP.NET

  26. 26

    trying Image Button in repeater Asp.net

  27. 27

    asp net dropdown selectedvalue/selectedindex not updating in repeater

  28. 28

    ASP.Net - Issues with Repeater / DataBinding

  29. 29

    Repeater in asp.net from DB with DropDownList

HotTag

Archive