| | |
Problem With Dropdowns, Loops, Databinding and Placeholders
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
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
| Thread Tools | Search this Thread |
.net 2.0 activexcontrol advice ajax alltypeofvideos application asp asp.net bc30451 bottomasp.net box browser button c# c#gridviewcolumn checkbox click commonfunctions confirmationcodegeneration css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dynamically edit expose feedback fileuploader fill flash form formatdecimal forms formview grid gridview gudi homeedition hosting iframe iis javascript jquery listbox login microsoft mono mouse mssql multistepregistration news numerical objects opera panelmasterpagebuttoncontrols parent radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security select silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking unauthorized validation vb.net video videos view virtualdirectory vista visualstudio web webapplications webdevelopemnt webprogramming webservice xml xsl youareanotmemberofthedebuggerusers





