Search code examples
axaptadynamics-ax-2009enterprise-portal

Dynamics AX EP - Create completely new dataset row


I need to make a completely new row in specified Dataset in Dynamics AX Enterprise Portal User Control (without editing this data in axgridview). I've developed code as follows:

CodeBehind:

protedted void NewDelegAxPopupParentControl_PopupClosed(object sender, EventArgs e)
{

    DataSet dataSet = this.AxDataSource.GetDataSet();
    DataSetView dataSetView = dataSet.DataSetViews[this.AxGridView1.DataMember];
    DataSetViewRow dataSetViewRow = dataSetView.AddNew();

    dataSetViewRow.SetFieldValue("ProjId", projid);
    dataSetViewRow.SetFieldValue("Destination_ITG", location);
    dataSetViewRow.SetFieldValue("DateFrom_ITG", DateTime.ParseExact(datefrom, "yyyy-MM-dd", CultureInfo.InvariantCulture));
    dataSetViewRow.SetFieldValue("DateTo_ITG", DateTime.ParseExact(dateto, "yyyy-MM-dd", CultureInfo.InvariantCulture));
    dataSetViewRow.SetFieldValue("Employee", "102");

    dataSetViewRow.EndEdit();
}

When i first time add new row to dataset - it works fine. When i want to add another row - instead of creating new - it updates previous one.

Any help in resolving this issue will be very appreciated.


Solution

  • You might be able to bypass the problem by letting AX do the creation.

    This is listed as the number 3 solution in The Code Workshop.