Rendering a derived drop down list in VS2005 designer view

P

postings

Hi

I have a control derived from a drop down list written in VB.NET
(ASP.NET 2.0) that dynamically displays listitems retrieved from an SQL
server database. My code works fine but when I go to designer view in
Visual Studio 2005 it renders a gray box displaying: "Error Creating
Control - MyDropDownList, object reference not set to an instance of an
object". Note the drop down list works perfectly in IE.

If I remove my code retrieving the values from SQL server and put in
static values, i.e.
----------------------------------------------------
Me.Items.Add(New ListItem("Select a Value", "0"))
Me.Items.Add(New ListItem("Test", "1"))
----------------------------------------------------

The drop down list will render in both the designer and IE.
So I am assuming that the VS2005 designer view will not render dynamic
listitems, but will render static listitems from dropdownlists.

In order to solve this problem I've looked at using:
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)

....to see if I can force rendering in the design view but no joy at
all, my approach isn't working here.

I don't really care if the designer renders the exact values from the
database, a couple of dummy values will do if necessary.

Can anybody help (I'm lost!).

Many thanks!

Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top