문제

I have an InfoPath Form built. What I am looking to do is have a reset button that clears and entire node of populated data. I have seen a few solutions out there but this seems like a relatively simple request of a page. Is there a quick way to reset an entire node to its default configuration?

Thanks in Advance!

Matt

도움이 되었습니까?

해결책

This seems to have solved it.

private void ClearNode(XPathNavigator nodeToClear)
{
    if (nodeToClear.HasChildren)
    {
        nodeToClear.MoveToFirstChild();
        do
        {
            ClearNode(nodeToClear);
        } while (nodeToClear.MoveToNext());
        nodeToClear.MoveToParent();
    }
    else
    {
        nodeToClear.SetValue(string.Empty);
    }
}

After that you just call whatever node you want cleared and pass it in as an XPathNavigator and away you go. It solved everything I was storing but I am curious how it would handle resetting fields with default values like a boolean or something.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top