473,425 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

Can't change properties of a databoud dropdownlist in a user contr

I have a databound dropdownlist in a user control (ascx file). In the
corresponding aspx page I would like to be able to change the selectedindex
of the dropdownlist. So I set up a property in the ascx file to do so.
However, I keep getting the error: object is not set to an instance of an
object. I think this is a timing error because if I hard code the values it
runs fine. Any help would be greatly appreciated.

*********************Aspx page **************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim tempUserControl = Page.LoadControl("populatedropdown.ascx")
tempUserControl.myProp = "Test"
end sub
'*******************Ascx page*************

Public Property myProp() As String
Get
Return dropdownlist1.SelectedIndex
End Get
Set(ByVal Value As String)
DropDownList1.Items.FindByValue(Value).Selected = True
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

Call populatedropdown()
End Sub

Function populatedropdown()
Dim vArray As DataTable
Dim dt As New DataTable()
Dim dr As DataRow
Dim ozaweb As New plnwrapper.wrapper()
dt = ozaweb.GetVillageTypes

DropDownList1.DataSource = dt
DropDownList1.DataTextField = dt.Columns(1).ColumnName
DropDownList1.DataValueField = dt.Columns(0).ColumnName
DropDownList1.DataBind()

End Function


Nov 23 '05 #1
0 775

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Roman | last post by:
I have built a simple user control that contains 2 buttons, a text box and a dropdownlist. When a button is clicked it sets the visible property of the textbox/dropdownlist and the button. ie the...
8
by: Alan Silver | last post by:
Hello, I'm trying to write a simple user control as an exercise (and 'cos it might be useful). I am trying to do a simple date picker, which consists of three drop down lists, one for the day,...
1
by: dx | last post by:
I'm extremely frustrated with ASP.NET...again! To me this should be as simple as setting oCheckBox.Checked = True.. yet for some reason it isn't. I have a user control (ascx) that that has a...
1
by: Kum | last post by:
Hi, I need help in asp.net dynamic textbox controls validation. I am creating textbox controls dynamically on a asp.net webpage. Now after creating the textboxes on the page I want to validate...
1
by: Nathan Sokalski | last post by:
I have a problem that is driving me crazy. I have a User Control composed of three DropDownLists that will be used to select a date. I have everything working except for one thing. When I select a...
0
by: ASP Developer | last post by:
I created a very simple user control that has one dropdownlist. I bind the dropdownlist to database results on load in an ascx file. I would like to do be able to change the selectedindex from...
3
by: Shawn | last post by:
Hi. I have a DataGrid with a DropDownList, like this: <asp:DropDownList id="ddlStatusCode" OnSelectedIndexChanged="SetDirty" runat="server"></asp:DropDownList> If the user selects a new value I...
5
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I guess this probably a very silly question. I am not sure if this can be done in classical asp. A button has to be clicked if a selection in drop down list has been changed. If not, a...
3
by: Lohboy | last post by:
Using ASP.NET and IE7. (Sorry if I am posting in the wrong forum but my problem seemed to be more related to the JavaScript side than the ASP.NET side.) I have two DropDownList controls the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.