Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 29th, 2008, 01:40 PM
Registered User
 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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






Similar Threads
Thread Thread Starter Forum Replies Last Post
FormView/ObjectDataSource/DropDownList Problem davidanderson ASP.NET 2.0 Professional 3 April 14th, 2007 02:50 AM
DropDownList Inside FormView Problem frogosteve ASP.NET 2.0 Basics 0 April 12th, 2007 10:30 AM
Validation controls and FormView templates bpdsmark BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 1 September 28th, 2006 08:56 AM
How to bind colors to controls in an formview leverell ASP.NET 2.0 Professional 0 May 31st, 2006 02:00 AM
Accessing Controls in FormView cryspe ASP.NET 2.0 Basics 0 May 16th, 2006 03:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.