【发布时间】:2015-12-11 06:06:46
【问题描述】:
我遇到了无法使用 DataList 命令重定向到另一个页面的问题。这是我的 aspx 代码。
<asp:DataList id="CategoryList"
OnItemCommand="Barcode_RowCommand"
BorderColor="black"
CellPadding="1"
CellSpacing="1"
RepeatDirection="Horizontal"
RepeatLayout="Table"
RepeatColumns="4"
BorderWidth="0"
runat="server" ItemStyle-HorizontalAlign="Center" ItemStyle-Font-Names="arial" ItemStyle-Font-Size="12px"
ItemStyle-ForeColor="#ffffff" style="margin-left:auto; margin-right:auto;">
我如何使用图像按钮处理命令
<asp:ImageButton ID="Add"
ImageUrl= '<%# "getImage.aspx?Barcode=" + Eval("Barcode") %>'
ForeColor="black"
runat="server"
Visible="true"
Width = "200px"
height ="170px"
CommandArgument='<%# Eval("Barcode")%>'
DataKeyField="Barcode"
CommandName="Add"></asp:ImageButton>
下面是我的 aspx.cs 代码
public void Barcode_RowCommand(Object sender, DataListCommandEventArgs e)
{
if (e.CommandName == "Add")
{
Response.Redirect("ProductDetail.aspx");
}
}
代码没有错误,但是当我单击图像按钮时,它不会将我重定向到 productdtail.aspx,而是在同一页面上。任何帮助或建议将不胜感激。再次感谢
【问题讨论】:
-
1.产品详细信息的 page_load 代码是什么?您是否在事件处理程序的 if 块处设置了断点? response.redirect 行被执行了吗?
-
在 Response.Redirect 中放置一个断点并检查给定的路径。
-
@SatyakiChatterjee 我还没有放任何产品细节的代码,我会放断点看看
-
感谢您抽出宝贵时间@SatyakiChatterjee,我解决了我的问题。
-
别忘了@rajeeshmenoth