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
 
Ad

Advertisements


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

Top