object reference not set to an instance of an object - InfoPath Dev
in

InfoPath Dev

Qdabra® qRules

Use our Google Custom Search for best site search results.

object reference not set to an instance of an object

Last post 02-13-2015 11:30 PM by Indresh. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 02-12-2015 12:03 AM

    object reference not set to an instance of an object

    In Infopath form , I am writing c# code for list item changed event , My requirement is I need to get the ID of the list item which is modified. I tried it by using int id = Int32.Parse(e.Site.SelectSingleNode("../@d:ID", NamespaceManager).Value); I am getting error as - "object reference not set to an instance of an object" Code is - public void TestEmp__Title_Changed(object sender, XmlEventArgs e) { // Write your code here to change the main data source. if (e.Operation == XmlOperation.ValueChange) { if (e.Site.Name == "d:Title" && e.OldValue != e.NewValue) { // Get the ID of the item to be changed int id = Int32.Parse(e.Site.SelectSingleNode("../ID", NamespaceManager).Value); } } When it reaches above step, error gets generated. Can you tell me what change need to be done. Thanks in advance . Regards Indresh
    Indresh
    Filed under:
  • 02-13-2015 11:58 AM In reply to

    Re: object reference not set to an instance of an object

    My guess is your XPath of ../ID is incorrect. Right click the node in the datasource task pane and select Copy XPath - what is the path to ID? I'm guessing it may "d:ID" so you'd need ../d:ID instead.

    Hilary Stoupa

  • 02-13-2015 11:30 PM In reply to

    Re: object reference not set to an instance of an object

    yes , that was issue . After modifying it worked . Thanks a lot .
    Indresh
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.