Error !Object reference not set to an instance of an object. !!! Help

Discussion in 'ASP .Net' started by Parthiv Joshi, Jul 2, 2004.

  1. I am getting this error when I am trying to create a listbox of 7
    textbox values on my page..In below code ( dateone to dateseven are
    label controls )..I want to collect the values of these label controls
    when the page executes..but I am getting above error...

    Dim weekdayslist As ListBox
    weekdayslist.Items.Add("dateone")
    weekdayslist.Items.Add("datetwo")
    weekdayslist.Items.Add("datethree")
    weekdayslist.Items.Add("datefour")
    weekdayslist.Items.Add("datefive")
    weekdayslist.Items.Add("datesix")
    weekdayslist.Items.Add("dateseven")

    For i As Int32 = 0 To weekdayslist.Items.Count - 1
    weekdayslist.Items(i).Selected = True
    lblErr.Text = weekdayslist.SelectedItem.Value &
    "<br>"
    Next
     
    Parthiv Joshi, Jul 2, 2004
    #1
    1. Advertising

  2. * (Parthiv Joshi) scripsit:
    > I am getting this error when I am trying to create a listbox of 7
    > textbox values on my page..In below code ( dateone to dateseven are
    > label controls )..I want to collect the values of these label controls
    > when the page executes..but I am getting above error...
    >
    > Dim weekdayslist As ListBox


    .... 'As New ListBox()'

    > weekdayslist.Items.Add("dateone")


    --
    Herfried K. Wagner [MVP]
    <URL:http://dotnet.mvps.org/>
     
    Herfried K. Wagner [MVP], Jul 2, 2004
    #2
    1. Advertising

  3. Parthiv Joshi

    Kalyan Guest

    Where is the "new" for ListBox?

    "Parthiv Joshi" <> wrote in message
    news:...
    > I am getting this error when I am trying to create a listbox of 7
    > textbox values on my page..In below code ( dateone to dateseven are
    > label controls )..I want to collect the values of these label controls
    > when the page executes..but I am getting above error...
    >
    > Dim weekdayslist As ListBox
    > weekdayslist.Items.Add("dateone")
    > weekdayslist.Items.Add("datetwo")
    > weekdayslist.Items.Add("datethree")
    > weekdayslist.Items.Add("datefour")
    > weekdayslist.Items.Add("datefive")
    > weekdayslist.Items.Add("datesix")
    > weekdayslist.Items.Add("dateseven")
    >
    > For i As Int32 = 0 To weekdayslist.Items.Count - 1
    > weekdayslist.Items(i).Selected = True
    > lblErr.Text = weekdayslist.SelectedItem.Value &
    > "<br>"
    > Next
     
    Kalyan, Jul 2, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Suresh Kojhani
    Replies:
    1
    Views:
    2,423
    Anushi
    Jul 29, 2004
  2. Pedro Correia
    Replies:
    0
    Views:
    642
    Pedro Correia
    Jul 25, 2003
  3. Lauchlan M
    Replies:
    1
    Views:
    2,388
    S. Justin Gengo
    Aug 18, 2003
  4. Tim Zych
    Replies:
    2
    Views:
    557
    Andy Gaskell
    May 15, 2004
  5. Replies:
    1
    Views:
    514
    Mark Rae [MVP]
    Sep 20, 2007
Loading...

Share This Page