One implication of this system is that a Web Part that is deployed in a sandboxed solution can be neither a provider nor a consumer Web Part in a Web Part connection. This is because each sandboxed Web Part renders entirely in a separate page object of its own. (Cross-page Web Part connections are possible with Web Parts that derive from the Microsoft.SharePoint.WebPartPages.WebPart
class, but that class is blocked by the shim Microsoft.SharePoint.dll
—see earlier in this topic.
Only Web Parts derived from the System.Web.UI.WebControls.WebParts.WebPart
class are supported in sandboxed solutions, and they do not allow cross-page Web Part connections.)
But you can think about the visual web part: HOW TO: Create a Sandbox Compatible Visual Web Part with the Visual Studio 2010 SharePoint Power Tools