Question

Asp.Net 2.0 framewrok - VB.Net application I have a UserControl containing a Asp.Net DropDownList.

Things already researched and \ or tried:

  • The control gets bound to data on page load inside if not Page.IsPostBack (only loads once)
  • ID proprety is set for control (ID = ddlMyControl)
  • AutoPostBack is set to true
  • EnableViewState on the control is set to true
  • AutoEventWireUp in the UserControl declaration is set to true
  • EnableEventValidation is set to false in the parent page

The control will not fire it's SelectedIndexChanged event no matter what I do. HELP !!

Thanks :)

Was it helpful?

Solution

I was running into a similar issue and it was because I left AutoPostBack="true" out of the control definition. In your original post, you said you had tried that but the posted code:

<uc3:TheControl ID="ucMyControl" runat="server" />

does not reflect the AutoPostBack property. I added that to mine and it took care of my problem. Hope that helps.

OTHER TIPS

I know it's very late but I thought it will help others who faced the same problem.

I'm assuming you want to fire the SelectedIndexChanged Event of a DropDownList which is already bound with some data!
For example [C#]

ddlMyDropDown.DataSource = listOfCustomers;
ddlMyDropDown.DataTextField = "CustomerName";
ddlMyDropDown.DataValueField = "CustomerID";
ddlMyDropDown.DataBind();
ddlMyDropDown.CauseValidation = false;

I'm assuming you are using asp.net (latest version).. maybe 4.0.

What about the "surounding" page. You could try your UserControl within another page?

How do you add the event handler? How do you include the use control? (When via code, may be to late?)

May be you could show some code ;-)

The UserControl is not being loaded dynamicaly but added to the parent page at design time in the HTML of the page

<uc3:TheControl ID="ucMyControl" runat="server" />

The event handler is codded in the code behind of the UserContorl itself - standard stuff:

 Protected Sub ddlMyThing_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlMyThing.SelectedIndexChanged
    'Do event stuff here.
End Sub

Have you set the onselectedindexchanged="ddlMyThing_SelectedIndexChanged" property of the ddl?

I think you need to set EnableEventValidation to True.

Check this out.

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22405007.html

Hope this helps.

Thanks,

Raja

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top