Hi Aaron,
Not sure what's going wrong in your situation. Are you creating controls dynamically?? Here's what I did (and what works for me):
User Control Markup (Test.ascx)
Code:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Test.ascx.vb" Inherits="MyControl" %>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:DropDownList>
User Control Code Behind (Test.ascx.
vb)
Code:
Partial Class MyControl
Inherits System.Web.UI.UserControl
Public ReadOnly Property MyDropDown() As DropDownList
Get
Return Me.DropDownList1
End Get
End Property
End Class
Page with the control: (Test.aspx)
Code:
<uc1:Test ID="Test1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" /></div>
where uc1:Test refers to my custom control called MyControl in the file Test.ascx.
Code behind of the page: (Test.aspx.
vb)
Code:
Partial Class Test
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Test1.MyDropDown.Items.RemoveAt(2)
End Sub
End Class
When I run this page and click the button, one item is removed from the list.
Does this work for you?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of
ASP.NET 2.0 Instant Results and
Beginning Dreamweaver MX / MX 2004