FormView - access DropDownList controls
Having an issue when trying to bind my dropdownlist to the datasource. Keep getting "Object reference not set to an instance of an object". Not sure what I'm doing wrong. I know that the data is coming back from the database.
If fvDetail.CurrentMode = FormViewMode.Insert Then
Dim viewable As Integer = 1
Dim DropDownList1 As DropDownList
DropDownList1 = CType(Me.fvDetail.FindControl("ddlCategoryInsert") , DropDownList)
DropDownList1.DataSource = specData.getCategory(viewable).Tables(0)
DropDownList1.DataTextField = "category_desc"
DropDownList1.DataValueField = "category_id"
DropDownList1.DataBind()
Dim DropDownList2 As DropDownList
DropDownList2 = CType(Me.fvDetail.FindControl("ddlManufacturerInse rt"), DropDownList)
DropDownList2.DataSource = specData.getManufacturer().Tables(0)
DropDownList2.DataTextField = "name"
DropDownList2.DataValueField = "manufacturer_id"
DropDownList2.DataBind()
Dim DropDownList3 As DropDownList
DropDownList3 = CType(Me.fvDetail.FindControl("ddlVendorInsert"), DropDownList)
DropDownList3.DataSource = specData.getVendor(viewable).Tables(0)
DropDownList3.DataTextField = "vendor_name"
DropDownList3.DataValueField = "vendor_no"
DropDownList3.DataBind()
End If
|