Wednesday, 22 May 2013

This code is used to add Multi select lookup in EP from AX table.


<td class="dynJoiningPart"><asp:Label ID="Label1" runat="server" Text="Publish to customer group"></asp:Label></td>

<td><asp:TextBox ID="SegmentGrpTxt" runat="server" Visible="true" Width="500"></asp:TextBox></td>

<td class="dynJoiningPart"><dynamics:AxLookup ID="SegmentsGroupID" runat="server" TargetControlId="SegmentGrpTxt"

ExtendedDataType="smmSegmentId" LookupType="EDT" AllowMarking="true"

OnLookup="SegmentsGroupID_Lookup" OnOkClicked="SegmentsGroupID_OkClicked">

</dynamics:AxLookup></td>

-----------------------------------------------------------------------------------------------------------------

protected void SegmentsGroupID_Lookup(object sender, AxLookupEventArgs e)

{

AxLookup lookup = (AxLookup)sender;

SegmentGrpTxt.Text = "";

// Create the lookup data set. The smmBusRelSegmentGroup table will be used.

Proxy.SysDataSetBuilder sysDataSetBuilder;

sysDataSetBuilder = Proxy.SysDataSetBuilder.constructLookupDataSet(AxSession.AxaptaAdapter, TableMetadata.TableNum(AxSession, "smmBusRelSegmentGroup"));

// Set the generated data set as the lookup data set.

lookup.LookupDataSet = new DataSet(AxSession, sysDataSetBuilder.toDataSet());

// Specify the fields for the lookup.

lookup.Fields.Add(AxBoundFieldFactory.Create(AxSession, lookup.LookupDataSetViewMetadata.ViewFields["SegmentId"]));

lookup.Fields.Add(AxBoundFieldFactory.Create(AxSession, lookup.LookupDataSetViewMetadata.ViewFields["Description"]));

// Specify the select field for the lookup.

lookup.SelectField = "SegmentId";


}


protected void SegmentsGroupID_OkClicked(object sender, AxLookupEventArgs e)

{

string retval = "";

// Look at each value returned from the multi-select lookup

foreach (DataSetViewRow row in e.LookupControl.LookupDataSetView.GetMarkedRowsSet())

{

// Retrieve the Work Order Number from the current marked row

retval = retval + row.GetFieldValue("SegmentId").ToString() + " - ";


}


// Display the results in a text box

SegmentGrpTxt.Text = retval;

}
-----------------------------------------------------------------------------------------------------------------------
protected int FillCustGroupList()
{
string fieldvalue;

int nrec = 0;
int rowcount = 0;
       
// Get the data set
DataSet ds = this.AvaSmmBusRelSegmentGroupDS.GetDataSet();
AxDataSourceView SegGroupDS = AvaSmmBusRelSegmentGroupDS.GetDataSourceView("smmBusRelSegmentGroup");
       
// Add the views for the data set to the list.
foreach (DataSetView dsv in ds.DataSetViews)
{
           

rowcount = dsv.GetTotalNumberOfRows();
 
           

for (int i = 1; i <= rowcount; i++)
{
nrec++;
               

fieldvalue = dsv.GetCurrent().GetFieldValue("SegmentId").ToString();
               
}
}
return nrec;

}

No comments:

Import and Export file from BLOB storage Account(Azure) in D365 F&O using X++

  Import and Export file from BLOB storage Account in D365 F&O using X++ Import: /// <summary> /// MKInventQualityOrderLineService...