Search:
Namespaces
Discussions
.NET v1.1
Feedback
inheriting from a datalist
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngcontrolsvb' list
.
Dave Hickey
Hello -
It seems to me, I read somewhere that you can inherit and customize an asp control, such as a datagrid, to add functionality, etc.
I would like to extend the asp:dropdownlist control, because I just want to add some common database code to it. Is there a way to do this?
When I try to
Inherits System.Web.UI.WebControls.DropDownList
it gives me an error saying that the control has to inherit from UserClass instead.
Any suggestions?
-Dave
Reply to this message...
Paul D. Murphy
This is a control I put together last night written in C# that inherits
from the
DropDownList
. VB should work the same way.
=20
=20
Paul
=20
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
=20
namespace Dots.WebControls
{
/// <summary>
/// This drop down list displays a list of United States
states & Canadian Provinces
/// using the common two letter abbrievation for the value
of the state option.
/// </summary>
[DefaultProperty("Text"),=20
ToolboxData("<{0}:USCanadaDropDownList
runat=3Dserver></{0}:USCanadaDropDownList>")]
public class USCanadaDropDownList :
System.Web.UI.WebControls.
DropDownList
{
[
Browsable(false)
]
public override
System.Web.UI.WebControls.
ListItemCollection
Items
{
get
{
// Create a new
list item
=20
System.Web.UI.WebControls.
ListItemCollection
returnCollection =3D
new
System.Web.UI.WebControls.
ListItemCollection
();
=20
// Add the
states
returnCollection.Add(new
ListItem
("Choose a State", ""));
returnCollection.Add(new
ListItem
("Outside US/ Canada", "UNK"));
returnCollection.Add(new
ListItem
("Alabama", "AL"));
returnCollection.Add(new
ListItem
("Alaska", "AK"));
returnCollection.Add(new
ListItem
("Alberta", "AB"));
returnCollection.Add(new
ListItem
("American Samoa", "AS"));
returnCollection.Add(new
ListItem
("Arizona", "AZ"));
returnCollection.Add(new
ListItem
("Arkansas", "AR"));
returnCollection.Add(new
ListItem
("Armed Forces America", "AA"));
returnCollection.Add(new
ListItem
("Armed Forces Europe", "AE"));
returnCollection.Add(new
ListItem
("Armed Forces Pacific", "AP"));
returnCollection.Add(new
ListItem
("British Columbia", "BC"));
returnCollection.Add(new
ListItem
("California", "CA"));
returnCollection.Add(new
ListItem
("Colorada", "CO"));
returnCollection.Add(new
ListItem
("Connecticut", "CT"));
returnCollection.Add(new
ListItem
("Delaware", "DE"));
returnCollection.Add(new
ListItem
("District Of Columbia", "DC"));
returnCollection.Add(new
ListItem
("Florida", "FL"));
returnCollection.Add(new
ListItem
("Georgia", "GA"));
returnCollection.Add(new
ListItem
("Guam", "GU"));
returnCollection.Add(new
ListItem
("Hawaii", "HI"));
returnCollection.Add(new
ListItem
("Idaho", "ID"));
returnCollection.Add(new
ListItem
("Illinois", "IL"));
returnCollection.Add(new
ListItem
("Indiana", "IN"));
returnCollection.Add(new
ListItem
("Iowa", "IA"));
returnCollection.Add(new
ListItem
("Kansas", "KS"));
returnCollection.Add(new
ListItem
("Kentucky", "KY"));
returnCollection.Add(new
ListItem
("Louisiana", "LA"));
returnCollection.Add(new
ListItem
("Maine", "ME"));
returnCollection.Add(new
ListItem
("Manitoba", "MB"));
returnCollection.Add(new
ListItem
("Maryland", "MD"));
returnCollection.Add(new
ListItem
("Massachusetts", "MA"));
returnCollection.Add(new
ListItem
("Michigan", "MI"));
returnCollection.Add(new
ListItem
("Minnesota", "MN"));
returnCollection.Add(new
ListItem
("Mississippi", "MS"));
returnCollection.Add(new
ListItem
("Missouri", "MO"));
returnCollection.Add(new
ListItem
("Montana", "MT"));
returnCollection.Add(new
ListItem
("Nebraska", "NE"));
returnCollection.Add(new
ListItem
("Nevada", "NV"));
returnCollection.Add(new
ListItem
("New Brunswick", "NB"));
returnCollection.Add(new
ListItem
("New Hampshire", "NH"));
returnCollection.Add(new
ListItem
("New Jersey", "NJ"));
returnCollection.Add(new
ListItem
("New Mexico", "NM"));
returnCollection.Add(new
ListItem
("New York", "NY"));
returnCollection.Add(new
ListItem
("Newfoundland", "NF"));
returnCollection.Add(new
ListItem
("North Carolina", "NC"));
returnCollection.Add(new
ListItem
("North Dakota", "ND")); =20
returnCollection.Add(new
ListItem
("Northwest Territories", "NT"));
returnCollection.Add(new
ListItem
("Nova Scotia", "NS"));
returnCollection.Add(new
ListItem
("Ohio", "OH"));
returnCollection.Add(new
ListItem
("Oklahoma", "OK"));
returnCollection.Add(new
ListItem
("Ontario", "ON"));
returnCollection.Add(new
ListItem
("Oregon", "OR"));
returnCollection.Add(new
ListItem
("Palau", "PW"));
returnCollection.Add(new
ListItem
("Pennsylvania", "PA"));
returnCollection.Add(new
ListItem
("Prince Edward Island", "PE"));
returnCollection.Add(new
ListItem
("Province du Quebec", "PQ"));
returnCollection.Add(new
ListItem
("Puerto Rico", "PR"));
returnCollection.Add(new
ListItem
("Rhode Island", "RI"));
returnCollection.Add(new
ListItem
("Saskatchewan", "SK"));
returnCollection.Add(new
ListItem
("South Carolina", "SC"));
returnCollection.Add(new
ListItem
("South Dakota", "SD"));
returnCollection.Add(new
ListItem
("Tennessee", "TN"));
returnCollection.Add(new
ListItem
("Texas", "TX"));
returnCollection.Add(new
ListItem
("Utah", "UT"));
returnCollection.Add(new
ListItem
("Vermont", "VT"));
returnCollection.Add(new
ListItem
("Virgin Islands", "VI"));
returnCollection.Add(new
ListItem
("Virginia", "VA"));
returnCollection.Add(new
ListItem
("Washington", "WA"));
returnCollection.Add(new
ListItem
("West Virginia", "WV"));
returnCollection.Add(new
ListItem
("Wisconsin", "WI"));
returnCollection.Add(new
ListItem
("Wyoming", "WY"));
returnCollection.Add(new
ListItem
("Yukon Territory", "YT"));
=20
=20
// Return it
return returnCollection;
}
}
}
}
=20
-----Original Message-----
From: Dave Hickey [mailto:
Click here to reveal e-mail address
]=20
Sent: Friday, August 17, 2001 2:54 PM
To: aspngcontrolsvb
Subject: [aspngcontrolsvb] inheriting from a datalist
=20
Hello -
=20
It seems to me, I read somewhere that you can inherit and customize an
asp control, such as a datagrid, to add functionality, etc.
=20
I would like to extend the asp:dropdownlist control, because I just want
to add some common database code to it. Is there a way to do this?
=20
When I try to=20
Inherits System.Web.UI.WebControls.
DropDownList
it gives me an error saying that the control has to inherit from
UserClass instead.
Any suggestions?
-Dave
| [aspngcontrolsvb] member
Click here to reveal e-mail address
=3D YOUR ID
|
http://www.asplists.com/asplists/aspngcontrolsvb.asp
=3D JOIN/QUIT
|
http://www.asplists.com/search
=3D SEARCH Archives
Reply to this message...
System.Web.UI.WebControls.DropDownList
System.Web.UI.WebControls.ListItem
System.Web.UI.WebControls.ListItemCollection
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com