Please help me reference a control on my datalist.

J

jm

I have this error:

Object reference not set to an instance of an object.

for:

Dim order_type As DropDownList = _
(CType(e.Item.FindControl("order_type"), DropDownList))

dim sqlString as string= "SELECT * FROM tblorders"

Dim conn As New OdbcConnection("DSN=mydsn")

conn.open()
dim ds as New DataSet()
Dim myDataAdapter as odbcdataadapter
myDataAdapter = New odbcdataadapter(sqlString, conn)
myDataAdapter.Fill(ds)

order_type.DataSource=ds <-dies here problem line; this is a
dropdownlist
order_type.datatextfield="order_long_desc"
order_type.datavaluefield="order_short_desc"
order_type.DataBind()

It is in a datalist. This is in the onitemcreated event. It failed on
the onitemdatabound also. I am trying to populate a dropdownlist. This
event is being called when "Edit" is clicked. It is not the initial
entry form. I have been trying everything to reference this control.
If I simply put the dim statement by itself, I get no error. Thank you
for saving my sanity.

Why is it telling me there is no control? I thought these events
mentioned are the last time to get TO the controls themselves. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top