View Single Post
  #5 (permalink)  
Old December 1st, 2005, 03:41 PM
steve35719 steve35719 is offline
Authorized User
Join Date: Nov 2005
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts

If I remove everything from the EditItemTemplate then my dropdownlist is gone. I've included a code-behind event to occur with a selection of the dropdownlist but I still keep getting an error.

Protected Sub MyMethod(ByVal sender As Object, ByVal e As System.EventArgs)

    Dim DropDownList1 As New System.Web.UI.WebControls.DropDownList
    Dim Label1 As New Label

    DropDownList1 = CType(Me.DetailsView1.FindControl("DropDownList1") , DropDownList)

    Label1 = CType(Me.DetailsView1.FindControl("Label1"), Label)
    Label1.Text = DropDownList1.SelectedItem.Text

    End Sub

Error Message:
"NullRefereceException was unhandled by user code.
Object reference not set to an instance of an object." which was in reference to:
Label1.Text = DropDownList1.SelectedItem.Text

Reply With Quote