in

InfoPath Dev

Problems with a code based repeating table in Infopaht 2007

Last post 09-28-2007 02:56 AM by szuppel. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 09-28-2007 02:56 AM

    • szuppel
    • Not Ranked
      Male
    • Joined on 09-28-2007
    • Switzerland
    • Posts 1

    Problems with a code based repeating table in Infopaht 2007

    Hi friends

     I try to programatically use a repeating table in a infopaht form to log State Changes in it. I figured out how to get on the repeating table, but I dont manage to really have it as I like. Always when I ad a child, it changes the first row that I had to clone. I'm using Infopaht 2007 and Visual Studio 2005.

    What I want to do: If someone changes the state of my form, or the state is changed by an event, I would like to write this into a repeating table, to log who has changed from what state to what new state with which event and when. e.g. username, open, closed, 2007-09-26T10:05:23

    I use this c# code to do this:

    private void AdNewRowToStateHistory(string StateChangeEvent, string NewState)

    {

    XPathNavigator State = MainDataSource.CreateNavigator().SelectSingleNode("//my:txtState", NamespaceManager);

    //Repeating Table

    XmlNamespaceManager nsmgr = NamespaceManager;

    XPathNavigator StateHistory = MainDataSource.CreateNavigator().SelectSingleNode("//my:Root/my:StateHistory", nsmgr);

    XPathNavigator StateHistoryDetail = MainDataSource.CreateNavigator().SelectSingleNode("//my:Root/my:StateHistory/my:StateHistoryDetail", nsmgr);

    XPathNavigator newNode = StateHistoryDetail.Clone();

    newNode.SelectSingleNode("my:rptStateUser",nsmgr).SetValue(System.Environment.UserName);

    newNode.SelectSingleNode("my:rptStateStateOld", nsmgr).SetValue(Convert.ToString(State));

    newNode.SelectSingleNode("my:rptStateStateNew", nsmgr).SetValue(NewState);

    newNode.SelectSingleNode("my:rptStateEvent", nsmgr).SetValue(StateChangeEvent);

    newNode.SelectSingleNode("my:rptStateTimestamp", nsmgr).SetValue(DateTime.Now.ToString("yyyy.MM.ddThh:mm:ss"));

    StateHistory.AppendChild(newNode);

     

    State.SetValue(
    Convert.ToString(NewState));

    }

    Samuel Zürcher
Page 1 of 1 (1 items)
Copyright © 2003-2007 Qdabra Software. All rights reserved.
View our Terms of Use.