Monday, July 2, 2012

ASP.NET DropDownList does not fire SelectedIndexChanged


In one of my working projects - an ASP.NET WebForms, I had a DropDownList control (with AutoPostBack = "true") that was bound to  a ADO.NET EntityFramework entities collection. When the tester tested the webform, the DDL was posting but the default element (which had ID = 0) was selected and the handler for SelectedIndexChanged in the code-behind was not fired.
After some banging my head to my desk for a couple of hours (because other DDLs were working fine), I looked inside the data that was bound to the DDL. And to my surprise, that specific row in the (Oracle) table had the ID = 0, and therefore, no SelectedIndexChanged.

So, check your data too before banging your head to the office desk! :)

Hope it helps someone ... someday...

No comments: