C# Select a row in a repeating table - part 2 - InfoPath Dev
in

InfoPath Dev

C# Select a row in a repeating table - part 2

Last post 10-12-2005 04:30 PM by Greg Collins. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 09-29-2005 07:27 AM

    C# Select a row in a repeating table - part 2

    Hi,

    I've been attempting to implement the suggestions discussed in
    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=450

    and the discussion topic:

    http://www.infopathdev.com/downloads/free/default.aspx?i=c56d9528ec4f4317a5bd469ac4e90b9d

    However, I must be missing some key point. In Infopath, I have a Master/Detail. Also, I have a row number text box. When a user enters a row number and press the corresponding 'Goto' button, I want the Master record found at the give row number to be selected. This is very similar to the discussion topic written up by Greg Collins. My guess is that I'm using the wrong CtrlID. However, I'm not sure what else to try.

    My code:

    private string _patientChartCrtlID = "CTRL1_6";
    private IXMLDOMNode _patientChartNodes = null;

    [InfoPathEventHandler(MatchPath="CTRL110_6", EventType=InfoPathEventType.OnClick)]
    public void CTRL110_6_OnClick(DocActionEvent e)
    {

    try
    {

    _patientChartNodes = thisXDocument.DOM.selectSingleNode("//Patient");
    _patientChartNodes = thisXDocument.DOM.firstChild;


    string newRow = thisXDocument.DOM.selectSingleNode("//my:Goto").text;


    thisXDocument.SetNamedNodeProperty(_patientChartNodes, _patientChartCrtlID, newRow);

    }
    catch(System.Exception ex)
    {
    thisXDocument.UI.Alert(ex.ToString());
    }

    }


    The line in the view.xsl file that I believe that I'm suppose to use to retrieve the CtrlID is:
    <table class="xdRepeatingTable msoUcTable xdMaster" title="" style="TABLE-LAYOUT: fixed; WIDTH: 594px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word; BORDER-BOTTOM-STYLE: none" border="1" xd:CtrlId="CTRL1_6" xd:masterID="CTRL1_6">

    My XML tree is
    Patient has many PatientCaseFiles
    PatientCaseFile has many PatientCharts

    Patient
    PatientCaseFile
    PatientChart

    The list of Patients are displayed by the master the record and I'm trying to goto a specific Patient Row. The net effect of the code above is nothing happens. The current row selected is the same as it was prior to hitting the 'Goto' button.

    Any help or in-sights would be much appreciated.

    Thanks,

    Mike M.
  • 09-30-2005 07:35 AM In reply to

    Re: C# Select a row in a repeating table - part 2

    You might be right on using the wrong Ctrl-ID if nothing is happening. It's easier than your making it out to be.

    1) Double-click on your button in design mode.
    2) The ctrl-ID of the button is in the box labeled "ID:" - You can even change it to something like "but_patient_goto" if you want to make your code more easily understandable.

    If this doesn't work, I don't know how much help I can lend you, I have pretty much no experience with master/detail tables - but they sound cool! Good luck.

    ---------------
    Matt Faus
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 09-30-2005 09:14 AM In reply to

    Re: C# Select a row in a repeating table - part 2

    The first parameter for SetNamedNodeProperty() needs to be the node to the table... or in your case I believe it should be //Patient. It should not be any of the row nodes.

    Also, for future reference, using .firstChild() is a bad habit because it could be a #TEXT node like a TAB or something else. It may not be an actual element. It is better to use a full XPath where ever possible, such as Patient/PatientCaseFile[1] ... where [1] specifies the first instance of PatientCaseFile.

    Greg Collins [InfoPath MVP]
    InfoPath Dev
  • 10-10-2005 03:19 PM In reply to

    Re: C# Select a row in a repeating table - part 2

    That worked thanks. I removed the line of code using .firstChild().

    Mike M.
  • 10-12-2005 04:30 PM In reply to

    Re: C# Select a row in a repeating table - part 2

    Always glad to be able to help!

    Greg Collins [InfoPath MVP]
    InfoPath Dev
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.