【发布时间】:2014-03-18 11:25:14
【问题描述】:
我创建了一个asp:Repeater,并用.ascx 控件填充:
protected void Page_Load(object sender, EventArgs e)
{
Repeater1.DataSource = listOfData;
Repeater1.DataBind();
}
在我的页面上:
<uc:Product runat="server"
ImportantData='<% #Eval("ImportantData") %>'
id="DetailPanel1" />
在Product.ascx.cs里面我有:
public int ImportantData{ get; set; }
protected void Page_Load(object sender, EventArgs e)
{
}
在Product.ascx 我有:
<asp:ImageButton ID="btn_Ok" runat="server"
onclick="btn_Ok_Click"
ImageUrl="~/image.png" />
问题是当我点击图片按钮时出现错误:
A critical error has occurred. Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page...
我已尝试将第一个代码更改为:
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
Repeater1.DataSource = listOfData;
Repeater1.DataBind();
}
// Repeater1.DataBind(); // and tried to put DataBind() here
}
但是当我点击图片按钮时,ImportantData 是空的。
我在这里做错了什么?
【问题讨论】:
-
ImportantData是从哪里来的?你确定绑定列表中的对象有它吗? -
你试过设置 EnableEventValidation="false" 吗?
-
“我用 .ascx 控件填充”让我怀疑。 listOfData 包含什么,它与
有什么关系? -
您能否就建议的解决方案或有关您的具体问题的更多信息提供一些反馈?