Link to home
Start Free TrialLog in
Avatar of gianitoo
gianitoo

asked on

LIST OF YEARS FOR MY DROPDOWN LIST

NEED A LIST OF YEARS IN ASP.NET 2.0
Avatar of _TAD_
_TAD_

ArrayList years = new ArrayList();

for (int i =1850;i<2021; i++)
     years.add(i);


This will create an array list with all of the years from 1850 to 2020.
Avatar of gianitoo

ASKER

how do i bind it here

   <asp:DropDownList ID="yearborn" runat="server">
                            <asp:ListItem>1976</asp:ListItem>
                            <asp:ListItem>1977</asp:ListItem>
                            <asp:ListItem>1978</asp:ListItem>
                        </asp:DropDownList>
Theres a solution that is faster than this,

use Generics

List<int> years = new Lis<int>();

for (int i =1850;i<2007; i++)
  years.Add(i)

and them

DropDownList ddl = new DropDownList();
ddl.DataSource = years;
ddl.DataBind();

or add directly on DropDownList

DropDownList ddl = new DropDownList();
for (int i = 2007;i > 1850; i--)
   ddl.Items.Add(i.ToString());

Any questions I am here to help you.

Regards, Felipe Lopes
ASKER CERTIFIED SOLUTION
Avatar of sr22ger
sr22ger

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
where are from felipe?  i am from peru

is this for VB.net
My example is in VB.net, Felipe's is in C#
Oops, forgot to declare the yr variable, either
If Not Page.IsPostBack Then
  For yr As Integer=1850 To 2020
    yearborn.item.add(yr)
    yearborn.item(yr).value = 'you can also set the value of each entry in the list here
    If yr = Date.Now.Year Then
      yearborn.item(yr).Selected = True
    End If
  Next yr
End If

Or
Dim yr As Integer
If Not Page.IsPostBack Then
  For yr=1850 To 2020
    yearborn.item.add(yr)
    yearborn.item(yr).value = 'you can also set the value of each entry in the list here
    If yr = Date.Now.Year Then
      yearborn.item(yr).Selected = True
    End If
  Next yr
End If
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'yr' is not declared.

Source Error:

 

Line 5:      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Line 6:          If Not Page.IsPostBack Then
Line 7:              For yr = 1850 To 2020
Line 8:                  yearborn.item.add(yr)
Line 9:      yearborn.item(yr).value = 'you can also set the value of each entry in the list here
 

Source File: C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx.vb    Line: 7
Sorry about that, see my post above.
Either Dim yr As Integer before the For loop, or start the For loop with For yr As Integer = 1850 To 2020
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'item' is not a member of 'System.Web.UI.WebControls.DropDownList'.

Source Error:

 

Line 7:          If Not Page.IsPostBack Then
Line 8:              For yr = 1850 To 2020
Line 9:                  yearborn.item.add(yr)
Line 10:     yearborn.item(yr).value = 'you can also set the value of each entry in the list here
Line 11:                 If yr = Date.Now.Year Then
 

Source File: C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx.vb    Line: 9



Show Detailed Compiler Output:


c:\windows\system32\inetsrv> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\crownroyal\8f1ff740\d419feaf\App_Web_eexmolch.dll" /D:DEBUG=1 /debug+ /win32resource:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\crownroyal\8f1ff740\d419feaf\eexmolch.res" /define:_MYTYPE=\"Web\" /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls  "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\crownroyal\8f1ff740\d419feaf\App_Web_eexmolch.0.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\crownroyal\8f1ff740\d419feaf\App_Web_eexmolch.1.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\crownroyal\8f1ff740\d419feaf\App_Web_eexmolch.2.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\crownroyal\8f1ff740\d419feaf\App_Web_eexmolch.3.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\crownroyal\8f1ff740\d419feaf\App_Web_eexmolch.4.vb"


Microsoft (R) Visual Basic Compiler version 8.0.50727.42
for Microsoft (R) .NET Framework version 2.0.50727.42
Copyright (c) Microsoft Corporation.  All rights reserved.

C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx.vb(9) : error BC30456: 'item' is not a member of 'System.Web.UI.WebControls.DropDownList'.

                yearborn.item.add(yr)
                ~~~~~~~~~~~~~        
C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx.vb(10) : error BC30456: 'item' is not a member of 'System.Web.UI.WebControls.DropDownList'.

    yearborn.item(yr).value = 'you can also set the value of each entry in the list here
    ~~~~~~~~~~~~~                                                                      
C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx.vb(10) : error BC30201: Expression expected.

    yearborn.item(yr).value = 'you can also set the value of each entry in the list here
                            ~                                                          
C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx.vb(12) : error BC30456: 'item' is not a member of 'System.Web.UI.WebControls.DropDownList'.

                    yearborn.item(yr).Selected = True
                    ~~~~~~~~~~~~~                    

 



Show Complete Compilation Source:


Line 1:    #ExternalChecksum("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx","{406ea660-64cf-4c82-b6f0-42d48172a799}","3A2539C6E74630FD7A326D3538B5A938")
Line 2:    '------------------------------------------------------------------------------
Line 3:    ' <auto-generated>
Line 4:    '     This code was generated by a tool.
Line 5:    '     Runtime Version:2.0.50727.42
Line 6:    '
Line 7:    '     Changes to this file may cause incorrect behavior and will be lost if
Line 8:    '     the code is regenerated.
Line 9:    ' </auto-generated>
Line 10:   '------------------------------------------------------------------------------
Line 11:  
Line 12:   Option Strict Off
Line 13:   Option Explicit On
Line 14:  
Line 15:   Imports Microsoft.VisualBasic
Line 16:   Imports System
Line 17:   Imports System.Collections
Line 18:   Imports System.Collections.Specialized
Line 19:   Imports System.Configuration
Line 20:   Imports System.Text
Line 21:   Imports System.Text.RegularExpressions
Line 22:   Imports System.Web
Line 23:   Imports System.Web.Caching
Line 24:   Imports System.Web.Profile
Line 25:   Imports System.Web.Security
Line 26:   Imports System.Web.SessionState
Line 27:   Imports System.Web.UI
Line 28:   Imports System.Web.UI.HtmlControls
Line 29:   Imports System.Web.UI.WebControls
Line 30:   Imports System.Web.UI.WebControls.WebParts
Line 31:  
Line 32:  
Line 33:   Partial Public Class _Default
Line 34:       Implements System.Web.SessionState.IRequiresSessionState
Line 35:      
Line 36:      
Line 37:       #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",18)
Line 38:       Protected WithEvents DropDownList1 As Global.System.Web.UI.WebControls.DropDownList
Line 39:      
Line 40:       #End ExternalSource
Line 41:      
Line 42:      
Line 43:       #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",25)
Line 44:       Protected WithEvents yearborn As Global.System.Web.UI.WebControls.DropDownList
Line 45:      
Line 46:       #End ExternalSource
Line 47:      
Line 48:      
Line 49:       #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",31)
Line 50:       Protected WithEvents Button1 As Global.System.Web.UI.WebControls.Button
Line 51:      
Line 52:       #End ExternalSource
Line 53:      
Line 54:      
Line 55:       #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 56:       Protected WithEvents form1 As Global.System.Web.UI.HtmlControls.HtmlForm
Line 57:      
Line 58:       #End ExternalSource
Line 59:      
Line 60:       Protected ReadOnly Property Profile() As System.Web.Profile.DefaultProfile
Line 61:           Get
Line 62:               Return CType(Me.Context.Profile,System.Web.Profile.DefaultProfile)
Line 63:           End Get
Line 64:       End Property
Line 65:      
Line 66:       Protected ReadOnly Property ApplicationInstance() As System.Web.HttpApplication
Line 67:           Get
Line 68:               Return CType(Me.Context.ApplicationInstance,System.Web.HttpApplication)
Line 69:           End Get
Line 70:       End Property
Line 71:   End Class
Line 72:  
Line 73:   Namespace ASP
Line 74:      
Line 75:       <System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()>  _
Line 76:       Public Class default_aspx
Line 77:           Inherits Global._Default
Line 78:           Implements System.Web.IHttpHandler
Line 79:          
Line 80:           Private Shared __initialized As Boolean
Line 81:          
Line 82:           Private Shared __stringResource As Object
Line 83:          
Line 84:           Private Shared __fileDependencies As Object
Line 85:          
Line 86:           Public Sub New()
Line 87:               MyBase.New
Line 88:               Dim dependencies() As String
Line 89:              
Line 90:               #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx.vb",912304)
Line 91:               CType(Me,System.Web.UI.Page).AppRelativeVirtualPath = "~/Default.aspx"
Line 92:              
Line 93:               #End ExternalSource
Line 94:               If (Global.ASP.default_aspx.__initialized = false) Then
Line 95:                   Global.ASP.default_aspx.__stringResource = Me.ReadStringResource
Line 96:                   dependencies = New String(1) {}
Line 97:                   dependencies(0) = "~/Default.aspx"
Line 98:                   dependencies(1) = "~/Default.aspx.vb"
Line 99:                   Global.ASP.default_aspx.__fileDependencies = Me.GetWrappedFileDependencies(dependencies)
Line 100:                  Global.ASP.default_aspx.__initialized = true
Line 101:              End If
Line 102:              Me.Server.ScriptTimeout = 30000000
Line 103:          End Sub
Line 104:          
Line 105:          Protected Overrides ReadOnly Property SupportAutoEvents() As Boolean
Line 106:              Get
Line 107:                  Return false
Line 108:              End Get
Line 109:          End Property
Line 110:          
Line 111:          Private Function __BuildControl__control3() As Global.System.Web.UI.HtmlControls.HtmlTitle
Line 112:              Dim __ctrl As Global.System.Web.UI.HtmlControls.HtmlTitle
Line 113:              
Line 114:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",7)
Line 115:              __ctrl = New Global.System.Web.UI.HtmlControls.HtmlTitle
Line 116:              
Line 117:              #End ExternalSource
Line 118:              Dim __parser As System.Web.UI.IParserAccessor = CType(__ctrl,System.Web.UI.IParserAccessor)
Line 119:              
Line 120:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",7)
Line 121:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl("Untitled Page"))
Line 122:              
Line 123:              #End ExternalSource
Line 124:              Return __ctrl
Line 125:          End Function
Line 126:          
Line 127:          Private Function __BuildControl__control2() As Global.System.Web.UI.HtmlControls.HtmlHead
Line 128:              Dim __ctrl As Global.System.Web.UI.HtmlControls.HtmlHead
Line 129:              
Line 130:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",6)
Line 131:              __ctrl = New Global.System.Web.UI.HtmlControls.HtmlHead("head")
Line 132:              
Line 133:              #End ExternalSource
Line 134:              Dim __ctrl1 As Global.System.Web.UI.HtmlControls.HtmlTitle
Line 135:              
Line 136:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",6)
Line 137:              __ctrl1 = Me.__BuildControl__control3
Line 138:              
Line 139:              #End ExternalSource
Line 140:              Dim __parser As System.Web.UI.IParserAccessor = CType(__ctrl,System.Web.UI.IParserAccessor)
Line 141:              
Line 142:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",6)
Line 143:              __parser.AddParsedSubObject(__ctrl1)
Line 144:              
Line 145:              #End ExternalSource
Line 146:              Return __ctrl
Line 147:          End Function
Line 148:          
Line 149:          Private Function __BuildControl__control5() As Global.System.Web.UI.WebControls.ListItem
Line 150:              Dim __ctrl As Global.System.Web.UI.WebControls.ListItem
Line 151:              
Line 152:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",19)
Line 153:              __ctrl = New Global.System.Web.UI.WebControls.ListItem
Line 154:              
Line 155:              #End ExternalSource
Line 156:              
Line 157:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",19)
Line 158:              __ctrl.Text = "USA"
Line 159:              
Line 160:              #End ExternalSource
Line 161:              Return __ctrl
Line 162:          End Function
Line 163:          
Line 164:          Private Function __BuildControl__control6() As Global.System.Web.UI.WebControls.ListItem
Line 165:              Dim __ctrl As Global.System.Web.UI.WebControls.ListItem
Line 166:              
Line 167:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",20)
Line 168:              __ctrl = New Global.System.Web.UI.WebControls.ListItem
Line 169:              
Line 170:              #End ExternalSource
Line 171:              
Line 172:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",20)
Line 173:              __ctrl.Text = "Canada"
Line 174:              
Line 175:              #End ExternalSource
Line 176:              Return __ctrl
Line 177:          End Function
Line 178:          
Line 179:          Private Sub __BuildControl__control4(ByVal __ctrl As System.Web.UI.WebControls.ListItemCollection)
Line 180:              Dim __ctrl1 As Global.System.Web.UI.WebControls.ListItem
Line 181:              
Line 182:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",18)
Line 183:              __ctrl1 = Me.__BuildControl__control5
Line 184:              
Line 185:              #End ExternalSource
Line 186:              
Line 187:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",18)
Line 188:              __ctrl.Add(__ctrl1)
Line 189:              
Line 190:              #End ExternalSource
Line 191:              Dim __ctrl2 As Global.System.Web.UI.WebControls.ListItem
Line 192:              
Line 193:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",18)
Line 194:              __ctrl2 = Me.__BuildControl__control6
Line 195:              
Line 196:              #End ExternalSource
Line 197:              
Line 198:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",18)
Line 199:              __ctrl.Add(__ctrl2)
Line 200:              
Line 201:              #End ExternalSource
Line 202:          End Sub
Line 203:          
Line 204:          Private Function __BuildControlDropDownList1() As Global.System.Web.UI.WebControls.DropDownList
Line 205:              Dim __ctrl As Global.System.Web.UI.WebControls.DropDownList
Line 206:              
Line 207:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",18)
Line 208:              __ctrl = New Global.System.Web.UI.WebControls.DropDownList
Line 209:              
Line 210:              #End ExternalSource
Line 211:              Me.DropDownList1 = __ctrl
Line 212:              __ctrl.ApplyStyleSheetSkin(Me)
Line 213:              
Line 214:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",18)
Line 215:              __ctrl.ID = "DropDownList1"
Line 216:              
Line 217:              #End ExternalSource
Line 218:              
Line 219:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",18)
Line 220:              __ctrl.AutoPostBack = true
Line 221:              
Line 222:              #End ExternalSource
Line 223:              
Line 224:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",18)
Line 225:              Me.__BuildControl__control4(__ctrl.Items)
Line 226:              
Line 227:              #End ExternalSource
Line 228:              Return __ctrl
Line 229:          End Function
Line 230:          
Line 231:          Private Function __BuildControl__control8() As Global.System.Web.UI.WebControls.ListItem
Line 232:              Dim __ctrl As Global.System.Web.UI.WebControls.ListItem
Line 233:              
Line 234:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",26)
Line 235:              __ctrl = New Global.System.Web.UI.WebControls.ListItem
Line 236:              
Line 237:              #End ExternalSource
Line 238:              
Line 239:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",26)
Line 240:              __ctrl.Text = "1976"
Line 241:              
Line 242:              #End ExternalSource
Line 243:              Return __ctrl
Line 244:          End Function
Line 245:          
Line 246:          Private Function __BuildControl__control9() As Global.System.Web.UI.WebControls.ListItem
Line 247:              Dim __ctrl As Global.System.Web.UI.WebControls.ListItem
Line 248:              
Line 249:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",27)
Line 250:              __ctrl = New Global.System.Web.UI.WebControls.ListItem
Line 251:              
Line 252:              #End ExternalSource
Line 253:              
Line 254:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",27)
Line 255:              __ctrl.Text = "1977"
Line 256:              
Line 257:              #End ExternalSource
Line 258:              Return __ctrl
Line 259:          End Function
Line 260:          
Line 261:          Private Function __BuildControl__control10() As Global.System.Web.UI.WebControls.ListItem
Line 262:              Dim __ctrl As Global.System.Web.UI.WebControls.ListItem
Line 263:              
Line 264:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",28)
Line 265:              __ctrl = New Global.System.Web.UI.WebControls.ListItem
Line 266:              
Line 267:              #End ExternalSource
Line 268:              
Line 269:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",28)
Line 270:              __ctrl.Text = "1978"
Line 271:              
Line 272:              #End ExternalSource
Line 273:              Return __ctrl
Line 274:          End Function
Line 275:          
Line 276:          Private Sub __BuildControl__control7(ByVal __ctrl As System.Web.UI.WebControls.ListItemCollection)
Line 277:              Dim __ctrl1 As Global.System.Web.UI.WebControls.ListItem
Line 278:              
Line 279:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",25)
Line 280:              __ctrl1 = Me.__BuildControl__control8
Line 281:              
Line 282:              #End ExternalSource
Line 283:              
Line 284:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",25)
Line 285:              __ctrl.Add(__ctrl1)
Line 286:              
Line 287:              #End ExternalSource
Line 288:              Dim __ctrl2 As Global.System.Web.UI.WebControls.ListItem
Line 289:              
Line 290:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",25)
Line 291:              __ctrl2 = Me.__BuildControl__control9
Line 292:              
Line 293:              #End ExternalSource
Line 294:              
Line 295:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",25)
Line 296:              __ctrl.Add(__ctrl2)
Line 297:              
Line 298:              #End ExternalSource
Line 299:              Dim __ctrl3 As Global.System.Web.UI.WebControls.ListItem
Line 300:              
Line 301:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",25)
Line 302:              __ctrl3 = Me.__BuildControl__control10
Line 303:              
Line 304:              #End ExternalSource
Line 305:              
Line 306:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",25)
Line 307:              __ctrl.Add(__ctrl3)
Line 308:              
Line 309:              #End ExternalSource
Line 310:          End Sub
Line 311:          
Line 312:          Private Function __BuildControlyearborn() As Global.System.Web.UI.WebControls.DropDownList
Line 313:              Dim __ctrl As Global.System.Web.UI.WebControls.DropDownList
Line 314:              
Line 315:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",25)
Line 316:              __ctrl = New Global.System.Web.UI.WebControls.DropDownList
Line 317:              
Line 318:              #End ExternalSource
Line 319:              Me.yearborn = __ctrl
Line 320:              __ctrl.ApplyStyleSheetSkin(Me)
Line 321:              
Line 322:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",25)
Line 323:              __ctrl.ID = "yearborn"
Line 324:              
Line 325:              #End ExternalSource
Line 326:              
Line 327:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",25)
Line 328:              Me.__BuildControl__control7(__ctrl.Items)
Line 329:              
Line 330:              #End ExternalSource
Line 331:              Return __ctrl
Line 332:          End Function
Line 333:          
Line 334:          Private Function __BuildControlButton1() As Global.System.Web.UI.WebControls.Button
Line 335:              Dim __ctrl As Global.System.Web.UI.WebControls.Button
Line 336:              
Line 337:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",31)
Line 338:              __ctrl = New Global.System.Web.UI.WebControls.Button
Line 339:              
Line 340:              #End ExternalSource
Line 341:              Me.Button1 = __ctrl
Line 342:              __ctrl.ApplyStyleSheetSkin(Me)
Line 343:              
Line 344:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",31)
Line 345:              __ctrl.ID = "Button1"
Line 346:              
Line 347:              #End ExternalSource
Line 348:              
Line 349:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",31)
Line 350:              __ctrl.Text = "Button"
Line 351:              
Line 352:              #End ExternalSource
Line 353:              Return __ctrl
Line 354:          End Function
Line 355:          
Line 356:          Private Function __BuildControlform1() As Global.System.Web.UI.HtmlControls.HtmlForm
Line 357:              Dim __ctrl As Global.System.Web.UI.HtmlControls.HtmlForm
Line 358:              
Line 359:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 360:              __ctrl = New Global.System.Web.UI.HtmlControls.HtmlForm
Line 361:              
Line 362:              #End ExternalSource
Line 363:              Me.form1 = __ctrl
Line 364:              
Line 365:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 366:              __ctrl.ID = "form1"
Line 367:              
Line 368:              #End ExternalSource
Line 369:              Dim __parser As System.Web.UI.IParserAccessor = CType(__ctrl,System.Web.UI.IParserAccessor)
Line 370:              
Line 371:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 372:              __parser.AddParsedSubObject(Me.CreateResourceBasedLiteralControl(456, 514, true))
Line 373:              
Line 374:              #End ExternalSource
Line 375:              Dim __ctrl1 As Global.System.Web.UI.WebControls.DropDownList
Line 376:              
Line 377:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 378:              __ctrl1 = Me.__BuildControlDropDownList1
Line 379:              
Line 380:              #End ExternalSource
Line 381:              
Line 382:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 383:              __parser.AddParsedSubObject(__ctrl1)
Line 384:              
Line 385:              #End ExternalSource
Line 386:              
Line 387:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 388:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl("<br />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"                    <br />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"                   "&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"                        "& _
Line 389:                          "WHEN WERE YOU BORN?<br />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"                        "))
Line 390:              
Line 391:              #End ExternalSource
Line 392:              Dim __ctrl2 As Global.System.Web.UI.WebControls.DropDownList
Line 393:              
Line 394:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 395:              __ctrl2 = Me.__BuildControlyearborn
Line 396:              
Line 397:              #End ExternalSource
Line 398:              
Line 399:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 400:              __parser.AddParsedSubObject(__ctrl2)
Line 401:              
Line 402:              #End ExternalSource
Line 403:              
Line 404:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 405:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl("<br />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"                        <br />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"                        "))
Line 406:              
Line 407:              #End ExternalSource
Line 408:              Dim __ctrl3 As Global.System.Web.UI.WebControls.Button
Line 409:              
Line 410:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 411:              __ctrl3 = Me.__BuildControlButton1
Line 412:              
Line 413:              #End ExternalSource
Line 414:              
Line 415:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 416:              __parser.AddParsedSubObject(__ctrl3)
Line 417:              
Line 418:              #End ExternalSource
Line 419:              
Line 420:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",10)
Line 421:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl("</div>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"               "&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"    "&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"    "))
Line 422:              
Line 423:              #End ExternalSource
Line 424:              Return __ctrl
Line 425:          End Function
Line 426:          
Line 427:          Private Sub __BuildControlTree(ByVal __ctrl As default_aspx)
Line 428:              
Line 429:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",1)
Line 430:              Me.InitializeCulture
Line 431:              
Line 432:              #End ExternalSource
Line 433:              Dim __parser As System.Web.UI.IParserAccessor = CType(__ctrl,System.Web.UI.IParserAccessor)
Line 434:              
Line 435:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",1)
Line 436:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3"& _
Line 437:                          ".org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<html xmlns=""http://www.w3.org/1"& _
Line 438:                          "999/xhtml"" >"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)))
Line 439:              
Line 440:              #End ExternalSource
Line 441:              Dim __ctrl1 As Global.System.Web.UI.HtmlControls.HtmlHead
Line 442:              
Line 443:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",1)
Line 444:              __ctrl1 = Me.__BuildControl__control2
Line 445:              
Line 446:              #End ExternalSource
Line 447:              
Line 448:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",1)
Line 449:              __parser.AddParsedSubObject(__ctrl1)
Line 450:              
Line 451:              #End ExternalSource
Line 452:              
Line 453:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",1)
Line 454:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<body>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"    "))
Line 455:              
Line 456:              #End ExternalSource
Line 457:              Dim __ctrl2 As Global.System.Web.UI.HtmlControls.HtmlForm
Line 458:              
Line 459:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",1)
Line 460:              __ctrl2 = Me.__BuildControlform1
Line 461:              
Line 462:              #End ExternalSource
Line 463:              
Line 464:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",1)
Line 465:              __parser.AddParsedSubObject(__ctrl2)
Line 466:              
Line 467:              #End ExternalSource
Line 468:              
Line 469:              #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx",1)
Line 470:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"</body>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"</html>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)))
Line 471:              
Line 472:              #End ExternalSource
Line 473:          End Sub
Line 474:          
Line 475:          
Line 476:          #ExternalSource("C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx.vb",912304)
Line 477:          Protected Overrides Sub FrameworkInitialize()
Line 478:              MyBase.FrameworkInitialize
Line 479:              SetStringResourcePointer(Global.ASP.default_aspx.__stringResource, 0)
Line 480:              Me.__BuildControlTree(Me)
Line 481:              Me.AddWrappedFileDependencies(Global.ASP.default_aspx.__fileDependencies)
Line 482:              Me.Request.ValidateInput
Line 483:          End Sub
Line 484:          
Line 485:          #End ExternalSource
Line 486:          
Line 487:          Public Overrides Function GetTypeHashCode() As Integer
Line 488:              Return -2105383257
Line 489:          End Function
Line 490:          
Line 491:          Public Overrides Sub ProcessRequest(ByVal context As System.Web.HttpContext)
Line 492:              MyBase.ProcessRequest(context)
Line 493:          End Sub
Line 494:      End Class
Line 495:  End Namespace
Line 496:  
 

yearborn.Item.Add(yr).

Also... there's really no need to post the 500 lines of code. The error and lines 7-11 are plenty.
If Not Page.IsPostBack Then
  For yr As Integer=1850 To 2020
    yearborn.items.add(yr)
    yearborn.items(yr).value = yr
    If yr = Date.Now.Year Then
      yearborn.items(yr).Selected = True
    End If
  Next yr
End If
sorry...

yearborn.Items.Add(yr.ToString())
sorry i did not mean to.   it somehow pasted it all.  my bad
Server Error in '/crownroyal' Application.
--------------------------------------------------------------------------------

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Source Error:


Line 7:              For yr As Integer = 1850 To 2020
Line 8:                  yearborn.Items.Add(yr)
Line 9:                  yearborn.Items(yr).Value = yr
Line 10:                 If yr = Date.Now.Year Then
Line 11:                     yearborn.Items(yr).Selected = True
 

Source File: C:\Inetpub\wwwroot\JMI\crownroyal\Default.aspx.vb    Line: 9
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
lmao ty DNT
wow u are good
well, I try