A rather long title for this post, but that's what it comes down to.
I've been struggling with some problems an couldn't find anything about this issue on the web, so I decided to post my findings.
Because it is possible to place a Web Part multiple times on a SharePoint web page, SharePoint Server will assign a unique identifier to each control (that is, a Web Part and some of its child controls¹) to be able to distinguish between Postbacks originating from different Web Parts. The unique ID can be found in the ID attribute of a HTML element and looks similar to this:
TopZone defines the location of the Web Part, along with its GUID. The bold part (_ctl1) denotes the ID of the control in question, a SELECT in my case.
However, this will not work: The location and the GUID of the Web Part is evaluated when the page is rendered. These values then serve as a prefix to the control ID (_ctl1) you set in your own code. You have to retrieve the location/GUID prefix along with the control ID and combine them to the actual HTML ID. Because Web Parts should derive from
Microsoft.SharePoint.WebPartPages.WebPart this is pretty easy to achieve.
// Combine the Web Part's ID and the control ID.
¹ Those with an ID or a NAME.