Click here to Skip to main content
15,924,935 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
i am using datalist to view image from database in imagebutton and want when clicked to image go to another page with id of this image to get the details of this image from database

this code of datalist
XML
asp:DataList ID="DataList1" runat="server"  RepeatColumns="3"  OnItemCommand="DataList1_ItemCommand" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Both" Width="719px"  >
        <ItemTemplate>
            <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl='<%#Eval("image")%>' CommandName="selectimage" Width=100 Height=100 /><br />




i am using this code in cs

C#
protected void DataList1_ItemCommand(object source,
        System.Web.UI.WebControls.DataListCommandEventArgs e)

    {

        if (e.CommandName == "selectimage")
        {

            int Id = int.Parse(e.CommandArgument.ToString());
            
            Response.Redirect("~/clothes3.aspx?Id=" + e.CommandArgument.ToString());

        }
    }


but get an exception when clicked on image but i do not the reason
Posted
Comments
Parwej Ahamad 1-Jul-11 15:17pm    
So post here exception too.
shimaa010 1-Jul-11 16:29pm    
the exception

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> 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.

1 solution

The error means what it says. If you do what it says in order to avoid this error, then your code will probably work. You can also google the exact error message to read what other people have done in this instance.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900