Reputation: 105
Im trying to add a button in my grid view that will redirect me to another page and pass the id of the movie. This is my code
<asp:Button ID="Button1" runat="server" CausesValidation="False"
PostBackUrl="~/Add/CheckMovie.aspx?movie=<%#Eval("mov_id")%>"
/>
A while back in a different app I used similar code and it worked fine
<a href="editUser.aspx?usr=<%# Eval("usr") %>"><%# Eval("usr") %></a>
Is it because Im using a different tag, or maybe because of the url ?
Upvotes: 2
Views: 4682
Reputation: 2433
as mentioned in the comment above, its because of the server tag inside the ASp:Button control. You can change it to a HTML button like so:
<button class="button" id="submitreorder" onclick="parent.location='<%=ResolveUrl("~/order/ShoppingCart") %>/delete/<%# Eval("Item_ID") %>'">Remove</button>
Upvotes: 1
Reputation: 25435
Depending on how you get the value of mov_id
you may be better adding the code to the page_load
method, something like this
HTML
<asp:Button ID="Button1" runat="server" CausesValidation="False" PostBackUrl="" />
Code Behind
Button1.PostBackUrl = "~/Add/CheckMovie.aspx?movie=" + mov_id;
Upvotes: 1
Reputation: 460058
PostBackUrl='<%# "~/Add/CheckMovie.aspx?movie=" + Eval("mov_id") %>'
Upvotes: 2