点击gridview图像按钮时,我遇到了一个非常奇怪的问题。我已经尝试了谷歌上发现的几乎所有解决方案,但没有一个能帮我解决问题。
当我点击gridview上的图像按钮时,它会出现以下错误“无效的回发或回调参数”
我也在绑定gridview!IsPostback代码块。但它仍然会出现同样的错误。
以下是我的代码块
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
if (Request.QueryString["res"] != null && Request.QueryString["res"].ToString() == "200")
{
DisplayMessage(true, MESSAGE_DISPLAY_TYPE.SUCCESS);
}
this.LoadData();
}
}
catch (Exception ex)
{
Logger.LogMessageToDB("Error - " + ex.Message, PageName, "ManageSpecials:" + System.Reflection.MethodInfo.GetCurrentMethod().Name);
}
}
private void LoadData()
{
try
{
DataSet objDS = Special.GetSpecialList();
gvSpecial.DataSource = objDS.Tables[0];
ObjSortDataTable = objDS.Tables[0];
gvSpecial.DataBind();
}
catch (Exception ex)
{
Logger.LogMessageToDB("Error - " + ex.Message, PageName, "ManageSpecials:" + System.Reflection.MethodInfo.GetCurrentMethod().Name);
}
}
protected void gvSpecial_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName == "Edit")
{
string cID = Convert.ToString(e.CommandArgument);
Response.Redirect("AddSpecials.aspx?do=edit&id=" + cID, false);
}
else if (e.CommandName == "Delete")
{
int cID = Convert.ToInt32(e.CommandArgument);
int intReturnValue = Special.DeleteSpecial(cID);
if (intReturnValue > 0)
{
this.DisplayMessage(true, MESSAGE_DISPLAY_TYPE.SUCCESS);
this.LoadData();
gvSpecial.DataBind();
}
}
}
catch (Exception ex)
{
Logger.LogMessageToDB("Error :- " + ex.Message, PageName, "ManageBanners :" + System.Reflection.MethodInfo.GetCurrentMethod().Name);
}
}
这里是我使用的gridview图像按钮
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" CssClass="grid_button" />
<ItemTemplate>
<asp:ImageButton ID="imgBtnDelete" runat="server" CommandName="Delete" CommandArgument='<%# Eval("ID")%>' AlternateText="Delete" ToolTip="Delete Special" OnClientClick="javascript:return confirm('Are you sure you want to delete?\nIf you delete then all data related to this specials will also be deleted.');" />
</ItemTemplate>
</asp:TemplateField>
任何人都可以帮我解决这个问题吗?
提前致谢。