我创建了一个
在
当我点击图像按钮时,出现错误:
我尝试将第一个代码更改为以下内容:
但是当我点击图像按钮时,
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
是从哪里获取的?你确定绑定列表中的对象都有它吗? - Wiktor Zychla