Search code examples
c#xmlformattinginfopath2010

Hide Repeating table programmatically


I have a label and a repeating table which is populated from a repeating field.

The field is assigned values (using InnerXML property) in code behind (getting from web service). So I want to hide the repeating table and the label as well in case there is no value available for the field.

  1. Could I do it in the code behind?

  2. Or how to do it using formatting rules? I have tried the rule with RepeatingField is blank but no luck.

UPDATE:

  • Screenshot from the table: Repeating table

  • Code behind from the form to populate data:

    string xmlString = String.Empty;
    foreach (var record in records)
    {
        xmlString += CreateGroup("StatementList");
        xmlString += CreateElement("Statement_ID", record.ID
        xmlString += CreateElement("Statement_Label", record.Label
        xmlString += CreateElement("Statement_Text", record.Text
        xmlString += EndGroup("StatementList");
    }
    
    if (!String.IsNullOrEmpty(statementXML))
    {
        XPathNavigator nodeStatement = Root.SelectSingleNode("/my:AuditForm/my:MasterData/my:StatementGroup", NamespaceManager);
        nodeStatement.InnerXml = statementXML;
    }
    

Solution

  • Try the below steps for hiding the object in Infopath

    If you need to hide Reapting table and lable in infopath then do as follow

    Click on Reapting Section
    
    Under Manage Rule Select Formatting
    
    Add a condition as the label is blank
    
    and check the check box for hide this control
    

    If you need to hide label alone in infopath then do as follow

    Click on that label
    
    Under Manage Rule Select Formatting
    
    Add a condition as the label is blank
    
    and check the check box for hide this control