Results 1 to 3 of 3

Thread: add into a listbox - "Object reference not set to an instance of an object."

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    128

    add into a listbox - "Object reference not set to an instance of an object."

    hello

    i need to produce a web page that has a button that takes a selected item from "listbox1" and adds it into "listbox2" via a dataset, this application needs to be used by many users at the same time.

    this is the code for the button...

    PHP Code:
        Private Sub btnAdd_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles btnAdd.Click
            Dim Tag 
    As DataRow
            Tag
    (1) = ListBox1.SelectedItem.Text
            dstSelectedTags
    .Tables("tblSelectedTags").Rows.Add(Tag)
            
    ListBox2.DataSource dstSelectedTags
            ListBox2
    .DataBind()
        
    End Sub 
    i am getting "Object reference not set to an instance of an object."

    what is wrong??

    please help
    thanks,
    tom

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Dim Tag As DataRow

    Should have the NEW keyword somewhere.

    Dim Tag As New DataRow

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Or it could be that the SelectedItem is nothing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width