Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 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 Professional 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 August 11th, 2007, 05:21 PM
Friend of Wrox
Join Date: Apr 2006
Location: , , .
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem with populating ddl in edit of detailsview


i defined a dropdownlist in an EditTemplate of a detailsview like this:

<asp:DropDownList ID="drop1" runat="server"></asp:DropDownList>

I want to populate it in code-behind; i tried this:

Protected Sub DetailsView1_ItemCreated(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.ItemCreated
        If DataControlRowState.Edit Then 'only in edit mode
            If DataControlRowType.DataRow Then 'only datarow
                Dim dd1 As DropDownList
                Dim z1 As ListItem
                Dim i As Integer
                dd1 = CType(DetailsView1.Rows(5).FindControl("drop1"),
                For i = 0 To 20
                z1 = New ListItem(i, i)
            End If
        End If
    End Sub

But i get the error:"Object reference not set to an instance of an object"
at line: dd1.Items.Add(z1)

Thanks for help

Old August 16th, 2007, 12:21 PM
Friend of Wrox
Join Date: Apr 2006
Location: , , .
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts

i found it.

 If DetailsView1.CurrentMode = DetailsViewMode.Edit Then

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Gridview to Edit NOT DetailsView ? kalel_4444 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 December 4th, 2008 11:36 PM
Populating DropDown List in DetailsView Edit Mode. kevorkian ASP.NET 2.0 Professional 2 June 9th, 2008 12:42 PM
how can selectedvalue of DDL make other DDL visibl hertendreef ASP.NET 2.0 Professional 4 May 20th, 2008 04:38 PM
Problem with updating the detailsview control rakesh225 ASP.NET 2.0 Professional 1 August 2nd, 2006 10:45 AM
DDL in DG (binding problem) RPG SEARCH ASP.NET 1.0 and 1.1 Basics 2 March 8th, 2005 12:50 PM

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