我有一个用户控件继续在MyPage.aspx
. 用户控件包含几个下拉列表;每个都有,Autopostback = true
但是当我运行代码并更改下拉项时,会触发其他事件,但不会触发SelectedIndexChanged
.
<asp:DropDownList ID="ddPages1" runat="server" EnableViewState="true" AutoPostBack="true"
onselectedindexchanged="ddPages1_SelectedIndexChanged">
</asp:DropDownList>
ascx 后面的代码:
protected void ddPages1_SelectedIndexChanged(object sender, EventArgs e)
{
...
}
ascx 也有ReportViewer
& 我正在将报告中的页数填充到下拉列表中。
protected override void Render(HtmlTextWriter writer)
{
TotalPages = ReportViewer1.LocalReport.GetTotalPages();
txtPageCount1.Text = Convert.ToString(TotalPages);
if (TotalPages > 0)
{
for (int i = 1; i <= TotalPages; i++)
{
ListItem listItem = new ListItem();
listItem.Value = i.ToString();
listItem.Text = i.ToString();
ddPages1.Items.Add(listItem);
}
}
base.Render(writer);
}