object reference not set to an instance of an object

Hi Guys , 

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.


Thanks

I

February 12th, 2015 2:31am

Could be a format error, did you try to see what value are you getting from e.Site.SelectSingleNode("../@d:ID", NamespaceManager).Value?
Free Windows Admin Tool Kit Click here and download it now
February 19th, 2015 4:33am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics