ASP.NET / C#: DropDownList SelectedIndexChanged in server control not firing

前端 未结 5 1484
我寻月下人不归
我寻月下人不归 2020-12-30 07:39

I\'m creating a server control that basically binds two dropdown lists, one for country and one for state, and updates the state dropdown on the country\'s selectedindexchan

5条回答
  •  情话喂你
    2020-12-30 08:03

    Is Viewstate turned on?

    Edit: Perhaps you should reconsider overriding the rendering function

      protected override void RenderContents(HtmlTextWriter output)
        {
            ddlCountries.RenderControl(output);
            ddlStates.RenderControl(output);
        }
    

    and instead add the dropdownlists to the control and render the control using the default RenderContents.

    Edit: See the answer from Dennis which I alluded to in my previous comment:

    Controls.Add ( ddlCountries );
    Controls.Add ( ddlStates );
    

提交回复
热议问题