Dropdownlist box problem

Discussion in 'ASP .Net' started by vladp, Aug 18, 2005.

  1. vladp

    vladp Guest

    Hi!
    Here is problem I got.
    I use vb.net and MSSQL Server 2000.
    My dropdownlist box gets information from view, and it works. However when I
    am trying to get information from the dropdownlist I get error message.
    Also during step by step debug dropPP.SelectedItem.Text gets value "NOTHING"

    Object reference not set to an instance of an object.
    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.NullReferenceException: Object reference not set
    to an instance of an object.

    Source Error:

    Line 442: If txtPD.Text <> "" Then .Item("dept_code") =
    txtPD.Text
    Line 443: If txtEffort.Text <> "" Then .Item("effort") =
    txtEffort.Text
    Line 444: If dropPP.SelectedItem.Text <> "" Then
    ..Item("dept_name") = dropPP.SelectedItem.Text
    Line 445: 'If dropBT.SelectedItem.Text <> "" Then
    ..Item("budget_title") = dropBT.SelectedItem.Text
    Line 446: If txtStart.Text <> "" Then .Item("efft_date_from") =
    txtStart.Text Else .Item("efft_date_from") = 0


    Thanks.

    Vlad
     
    vladp, Aug 18, 2005
    #1
    1. Advertisements

  2. It's kind of hard to give a full answer using what you have given, but one
    personal recommendation of mine that often helps me avoid errors is to never
    write code that refers to a property without putting the object/variable
    name with it. What this means is that instead of writing

    ..Item("dept_code")

    Write

    OBJECTVARIABLE.Item("dept_code")

    Doing this can make your code easier to understand when debugging as well as
    help avoid errors to begin with. Good luck!
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "vladp" <> wrote in message
    news:uy$...
    > Hi!
    > Here is problem I got.
    > I use vb.net and MSSQL Server 2000.
    > My dropdownlist box gets information from view, and it works. However when
    > I am trying to get information from the dropdownlist I get error message.
    > Also during step by step debug dropPP.SelectedItem.Text gets value
    > "NOTHING"
    >
    > Object reference not set to an instance of an object.
    > 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.NullReferenceException: Object reference not set
    > to an instance of an object.
    >
    > Source Error:
    >
    > Line 442: If txtPD.Text <> "" Then .Item("dept_code") =
    > txtPD.Text
    > Line 443: If txtEffort.Text <> "" Then .Item("effort") =
    > txtEffort.Text
    > Line 444: If dropPP.SelectedItem.Text <> "" Then
    > .Item("dept_name") = dropPP.SelectedItem.Text
    > Line 445: 'If dropBT.SelectedItem.Text <> "" Then
    > .Item("budget_title") = dropBT.SelectedItem.Text
    > Line 446: If txtStart.Text <> "" Then .Item("efft_date_from") =
    > txtStart.Text Else .Item("efft_date_from") = 0
    >
    >
    > Thanks.
    >
    > Vlad
    >
    >
     
    Nathan Sokalski, Aug 20, 2005
    #2
    1. Advertisements

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. mr2_93
    Replies:
    1
    Views:
    3,908
    mr2_93
    Oct 2, 2005
  2. tshad
    Replies:
    8
    Views:
    2,484
    tshad
    Oct 19, 2005
  3. =?Utf-8?B?SnVhbmpv?=

    GridView: Filtr DropDownList from another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    2,055
    =?Utf-8?B?SnVhbmpv?=
    Dec 23, 2005
  4. =?Utf-8?B?SnVhbmpv?=

    GridView: Filter DropDownList for another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 29, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,504
    =?Utf-8?B?SnVhbmpv?=
    Dec 29, 2005
  5. Gnarlodious
    Replies:
    4
    Views:
    17,990
    elizas
    May 5, 2010
  6. keithb
    Replies:
    1
    Views:
    12,780
    shauns1
    Nov 1, 2006
  7. S_K
    Replies:
    5
    Views:
    987
    Eliyahu Goldin
    Nov 14, 2007
  8. vladp
    Replies:
    0
    Views:
    443
    vladp
    Aug 18, 2005
Loading...