Object reference not set to an instance of an object.

Discussion in 'ASP .Net Web Controls' started by David, Oct 16, 2003.

  1. David

    David Guest

    Using a COM object to retrieve data from a SQL Server (middle tier).
    The COM object returns the data in XML format.
    In VB.NET, run the following Page Load code to obtain the XML string
    and to transform it so that a <SELECT> drop-down appears on the
    screen:

    ....
    Dim XMLString As String
    Dim myUser As System.Security.Principal.WindowsIdentity
    Dim myClient As dClient.ITClient
    Dim myXMLDoc As System.Xml.XmlDocument = New
    System.Xml.XmlDocument
    Dim myXMLTrans As System.Xml.Xsl.XslTransform = New
    System.Xml.Xsl.XslTransform

    'Show the current User
    myUser = System.Security.Principal.WindowsIdentity.GetCurrent()
    ResultName.InnerHtml() = "<BR>Welcome, " +
    myUser.Name.Substring(CInt(myUser.Name.IndexOf("\") + 1),
    CInt(CInt(myUser.Name.Length) - myUser.Name.IndexOf("\") - 1)) +
    "&nbsp;&nbsp;"

    'Fill the first drop down list with list of Clients
    myClient = CreateObject("dClient.TClient")
    XMLString = myClient.Select("select ridClient, valName from
    tblClient").ToString
    myXMLDoc.LoadXml(XMLString.ToString)
    myXMLTrans.Load(Server.MapPath("styles1.xsl"))
    Xml2.Document = myXMLDoc
    Xml2.Transform = myXMLTrans

    ....

    This results in a <SELECT id> box (with values) appearing in place of
    the XML (System.Web.UI.WebControls.Xml) control on the HTML page.
    i.e.:
    ....
    Client:
    <?xml version="1.0" encoding="utf-8"?>
    <SELECT id="dropDownClient" name="dropDownClient"
    runat="server"><OPTION></OPTION><OPTION>Max.
    I.T.</OPTION><OPTION>APCS</OPTION><OPTION>The Age</OPTION></SELECT>
    <input type="submit" name="cmdSelect" value="Select" id="cmdSelect" />
    ....

    However, when I try, in the cmdSelect.Click event of the button to
    access the value of the dropDownClient using dropDownClient.Value, I
    get the Object reference not set to an instance of an object error.
    So, the question is, what am I missing? I also do have the line:

    Protected WithEvents dropDownClient As
    System.Web.UI.HtmlControls.HtmlSelect

    at the top of the code page, but makes no difference.
    David, Oct 16, 2003
    #1
    1. Advertising

  2. David

    Sohail Guest

    >-----Original Message-----
    >However, when I try, in the cmdSelect.Click event of the

    button to
    >access the value of the dropDownClient using

    dropDownClient.Value, I
    >get the Object reference not set to an instance of an

    object error.
    >So, the question is, what am I missing? I also do have

    the line:
    >
    >Protected WithEvents dropDownClient As
    >System.Web.UI.HtmlControls.HtmlSelect
    >
    >at the top of the code page, but makes no difference.
    >.


    The problem is likely that you are running an antivirus
    software. Disable this. I had this problem and it was a
    bitch to solve. What happens is that your antivirus (or
    some similar prog) scans your global.*x file and aspnet
    thinks that its been changed so it recompiles and you lose
    all your variables.

    Good luck
    Sohail, Oct 16, 2003
    #2
    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. Parthiv Joshi
    Replies:
    2
    Views:
    679
    Kalyan
    Jul 2, 2004
  2. Suresh Kojhani
    Replies:
    1
    Views:
    2,376
    Anushi
    Jul 29, 2004
  3. Chris Fink
    Replies:
    2
    Views:
    4,082
    David Waz...
    Jul 3, 2003
  4. yysiow
    Replies:
    1
    Views:
    429
    Kevin Spencer
    Jul 12, 2003
  5. Replies:
    1
    Views:
    476
    Mark Rae [MVP]
    Sep 20, 2007
Loading...

Share This Page