473,394 Members | 1,726 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,394 software developers and data experts.

Can't access databound dropdownlist properties in user control

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 the aspx page. So I created a
property in the ascx file to expose the selected index property. However,
when I attempt to change the selectedindex I get the error: object is not set
to an instance of an object". 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 = "myval"

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 populatedrowdown()
End Sub

Function populatedrowdown()

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 19 '05 #1
0 1168

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

Similar topics

2
by: anastasia | last post by:
I have the following code (this is a snippet): InitDBConn(); OpenDBConnection(); OleDbCommand cmdRidge = new OleDbCommand("SELECT * FROM TRDRidgeTypes", oleDbConn); OleDbDataReader...
1
by: Vi | last post by:
Hi, I have a pop-up window in which I have 3 WebControls.DropDownList controls. I make my selections and when I submit the page, in the code behind page one control has the right value for...
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 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...
0
by: moi | last post by:
Hello, With ASP.NET 2 , i have two dropdownlist, one "A" (not in a formview) in the web page and other one "B" in a Insert Template in a formview. There's a link (parameter between this two...
1
by: odd.morten.sveas | last post by:
Hi I'm building a web site where some users can create receivables (invoices). This website will support several organisations and different users migth have responibility for more that one...
5
by: maurban | last post by:
Hi there experts, I have a gridview with a couple textboxes and a dropdownlist. I'm trying to insert a default value into my database driven dropdownlist. I'm doing this in the rowdatabound...
3
by: ssims | last post by:
For some reason my databound DropDownList will not populate. I've tried a variety of things...here's the latest. - I pulled a DropDownList on to the page. - Then I pulled a SqlDataAdapter and...
2
by: Cirene | last post by:
In my databound datagrid i have a databound dropdownlist, like this: <asp:DropDownList ID="ddlAvail0" runat="server" SelectedValue='<%# Bind("AvailMon") %>'> <asp:ListItem></asp:ListItem>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.