P
postings
Hi
This is (more or less) a repost from last week. Sorry I'm pretty
despirate for a soltution and hope I get better luck this time! Would
you mind looking at this? - Thanks....
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 when I look at the control in Design(er) 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."
Could somebody give me a pointer on how I can render
this control? Would you not expect the control to render in Visual
Studio.Net 2005
Many thanks
Alex
---------------------------------------------------->
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.ConnectionStrings("MainConnStr").ConnectionString)
Connection.Open()
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),
reader.GetString(0)))
End While
reader.Close()
Connection.Close()
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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<Mycontrol:ddlCountry runat="server" ID="ddlCountry"/>
</form>
</body>
</html>
<----------------------------------------------------
This is (more or less) a repost from last week. Sorry I'm pretty
despirate for a soltution and hope I get better luck this time! Would
you mind looking at this? - Thanks....
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 when I look at the control in Design(er) 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."
Could somebody give me a pointer on how I can render
this control? Would you not expect the control to render in Visual
Studio.Net 2005
Many thanks
Alex
---------------------------------------------------->
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.ConnectionStrings("MainConnStr").ConnectionString)
Connection.Open()
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),
reader.GetString(0)))
End While
reader.Close()
Connection.Close()
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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<Mycontrol:ddlCountry runat="server" ID="ddlCountry"/>
</form>
</body>
</html>
<----------------------------------------------------