470,596 Members | 1,610 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

Rendering a derived control in design view (VS2005)


The code below compiles and works. It's a control derived from a drop
down list that displays countries for the user to select.
My issue is that is I look in the drop down list in Design view of
Visual Studio 2005 (final), rather than rendering the dropdownlist, it
renders a gray box displaying:
"Error Creating Control - ddlCountry, object reference not set to an
instance of an object."

Is this normal? Could somebody give me a pointer on how I can render
this control?
Code below.

Many thanks



Imports Microsoft.VisualBasic

Namespace Testing
Public Class ddlCountry
Inherits DropDownList

Public Sub New()
Me.Items.Add(New ListItem("Select a Country", "0"))
Dim Connection As New
SqlConnection(ConfigurationManager.ConnectionStrin gs("MainConnStr").ConnectionString)
Dim command As New SqlCommand("SELECT CountryID, Country
FROM Countries ORDER BY Country", Connection)
Dim reader As SqlDataReader = command.ExecuteReader
While reader.Read
Me.Items.Add(New ListItem(reader.GetString(1),
End While
End Sub
End Class
End Namespace


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb"
Inherits="test" %>
<%@ Register Namespace="Testing" TagPrefix="MyControl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<form id="form1" runat="server">
<Mycontrol:ddlCountry runat="server" ID="ddlCountry"/>



Feb 1 '06 #1
0 1133

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by threecrans | last post: by
3 posts views Thread by David Whitney | last post: by
3 posts views Thread by kurt sune | last post: by
2 posts views Thread by Paul Cheetham | last post: by
4 posts views Thread by AG | last post: by
2 posts views Thread by Chris | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.