Object reference not set in ddl

D

David C

I have a drop down list control in a GridView that I want to grab the
SelectedValue in a SelectedIndexChanged event. I am getting an "Object
reference not set..." error on the line below that sets a reference to a
DropDownList via FindControl. I checked the spelling and control ID and all
is fine. Can someone help me find the reason for this error? Thanks.


Protected Sub ddlTypeID_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs)
Dim row As GridViewRow = GridView1.SelectedRow
Dim ddl As DropDownList = row.FindControl("ddlTypeID")
If ddl.SelectedValue = -1 Then
'some code here
End If
End Sub
 

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
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top