急!! 在用户控件中动态加载自定义控件的事件不能响应 高手给看看
我在一个用户控件中自定义加载linkbutton 并且注册了事件 但是事件不能响应 如果相同的代码写在别的页面就好使 不解 代码如下::
for (int i = 1; i <= totalPage; i++)
{
ddlSelectpage.Items.Add("第"+i.ToString()+"页");
LinkButton link = new LinkButton();
link.Text = i.ToString();
link.CssClass = "linkbutton";
link.Click += new EventHandler(link_Click);
Label4.Controls.Add(link);
}
void link_Click(object sender, EventArgs e)///函数中的代码不要紧 关键是现在程序不能进入此函数
{
currentNumber = Convert.ToInt32((sender as LinkButton).Text.ToString());
if (DeparmentID != -1)
{
DataList1.DataSource = GetProductList.getPrductlistByDepartmentID(DeparmentID, currentNumber, MaximumRows, DescriptionLength, out pageNumber, out totalPage);
}
else
if (CategoryID != 0)
{
DataList1.DataSource = GetProductList.getPrductlistByCategoryID(CategoryID, currentNumber, MaximumRows, DescriptionLength, out pageNumber, out totalPage);
}
else
{
DataList1.DataSource = GetProductList.getProductList(currentNumber, maximumRows, out pageNumber, out totalPage);
}
DataList1.DataBind();
Checkbutton();
}
protected void ProductBindByDepartmentID()
{
currentNumber = Convert.ToInt32(WebConfigurationManager.AppSettings["currentNumber"].ToString());
//maximumRows = Convert.ToInt32(WebConfigurationManager.AppSettings["MaximumRows"].ToString());
DescriptionLength = Convert.ToInt32(WebConfigurationManager.AppSettings["DescriptionLength"].ToString());
DataList1.DataSource = GetProductList.getPrductlistByDepartmentID(DeparmentID, currentNumber, MaximumRows, DescriptionLength, out pageNumber, out totalPage);
DataList1.DataBind();
for (int i = 1; i <= totalPage; i++)
{
ddlSelectpage.Items.Add("第" + i.ToString() + "页");
}
ddlSelectpage.SelectedIndex = currentNumber - 1;
}
各位给说说能有什么原因给影响的 在别的地方就好使
[[it] 本帖最后由 wang232504 于 2008-6-25 20:48 编辑 [/it]]