Thursday 25 July 2013

EP: Multi Select & Loop DataSet (Looping Data set in C#)





When you set the AllowMarking property to true, the user can mark multiple rows in the grid. You may want to know which rows the user has marked. The following example shows how to use the GetMarkedRowsSet method for the data source view to retrieve the set of marked rows. In this example, the name of each marked row is added to a list box.

This example uses the .NET Business Connector to access data. It requires access to the following namespaces:

C#

using Microsoft.Dynamics.AX.Framework.Portal.Data;

using Microsoft.Dynamics.Framework.BusinessConnector.Session;

using Microsoft.Dynamics.Framework.BusinessConnector.Adapter;

 

The following code for a button retrieves the list of marked rows.

C#

protected void Button1_Click(object sender, EventArgs e)

{

    // Create a container.

    IAxaptaContainerAdapter recordIds = this.AxSession.AxaptaAdapter.CreateAxaptaContainer();

 

    // Get the marked rows.

    IReadOnlySet rows = this.AxDataSource1.GetDataSourceView("FCMRooms").DataSetView.GetMarkedRowsSet();

 

    // Create an enumerator to examine each marked row.

    IEnumerator enumRows = rows.GetEnumerator();

 

    DataSetViewRow row;

    string description;

 

    // Clear the list box.

    ListBox1.Items.Clear();

 

    while (enumRows.MoveNext())

    {

        // Get the current row.

        row = (DataSetViewRow)enumRows.Current;

 

        // Retrieve the name of the room.

        description = row.GetFieldValue("RoomName").ToString();

 

        // Add the item to the list box.

        ListBox1.Items.Add(description);

    }

}

 

No comments:

Update NuGet package to new MS D365FO version

1. Import the NuGet package files from LCS for that particular version please take the PU version files only. a. Goto LCS-->Asset Libra...