| | |
Problem With Dropdowns, Loops, Databinding and Placeholders
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2005
Posts: 11
Reputation:
Solved Threads: 0
I'm in the process of trying to convert a website from classic ASP to .NET and while most of it has actually gone pretty well, this one particular page is driving me insane.
It should, in theory, be simple: One input box and three dropdown lists (for day, month and year). Where I'm having the problem is in getting the year list (in particular, though the same issue applies to the day list) to populate using a for loop (so that I can program it to automatically show current year plus five).
If I use the code I've got in a regular page (either code behind or otherwise) with no master page, everything works great.
As soon as it goes into the actual website page (which does employ a master page), it gives me a "Object reference not set to an instance of an object." error.
The sub I'm running is as follows:
Can anyone see what I've screwed up?
It should, in theory, be simple: One input box and three dropdown lists (for day, month and year). Where I'm having the problem is in getting the year list (in particular, though the same issue applies to the day list) to populate using a for loop (so that I can program it to automatically show current year plus five).
If I use the code I've got in a regular page (either code behind or otherwise) with no master page, everything works great.
As soon as it goes into the actual website page (which does employ a master page), it gives me a "Object reference not set to an instance of an object." error.
The sub I'm running is as follows:
ASP.NET Syntax (Toggle Plain Text)
Sub Populate_YearList() 'Year list can be extended Dim intYear As Integer Dim MainContent As ContentPlaceHolder = CType(Page.Master.FindControl("ContentPlaceHolder2"), ContentPlaceHolder) Dim DropDownList4 As DropDownList = CType(MainContent.FindControl("DropDownList4"), DropDownList) For intYear = 2009 To 2015 DropDownList4.Items.Add(CStr(intYear)) Next DropDownList4.Items.FindByValue(CStr(2013)).Selected = True End Sub
Can anyone see what I've screwed up?
![]() |
Similar Threads
- Loop problem (Assembly)
- Two loops (Assembly)
- Re: Turbo C help (C)
- Am i doing something wrong? (C++)
- newbie c++ help (C++)
- insert datetime into the database (C#)
- I need a project ;P (C++)
- merged:nesting loops (C++)
- File parsing in 'C' (C)
Other Threads in the ASP.NET Forum
- Previous Thread: Problem with sending (') in string
- Next Thread: DropdownList DataBinding
Views: 257 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor application asp asp.net bc30451 bottomasp.net box browser button c# checkbox commonfunctions complex connection dataaccesslayer database datagridview datagridviewcheckbox datalist development dgv dropdownlist dynamically edit editing expose feedback fileuploader fill flash form formatdecimal formview google gridview gudi iframe iis javascript list listbox login microsoft migration mono mouse mssql news numerical opera panelmasterpagebuttoncontrols parent problem project radio redirect registration relationaldatabases reportemail richtextbox rows save schoolproject search security select services session silverlight smartcard smoobjects software sql sql-server sqlserver2005 suse textbox theft tracking unauthorized validation vb.net video videos view vista visualstudio web webapplications webdevelopemnt webprogramming webservice xsl youareanotmemberofthedebuggerusers





