To get the bound field values and assing value to field in Ep

Hi,

Below are the sample code to get the value of the control as well as assign the value to control.

To get the bound field values & get field

A)  To get field value

#region Other functions

    static AxBoundField GetField(DataControlFieldCollection fields, string name)

    {

        foreach (DataControlField field in fields)

        {

            AxBoundField boundField = field as AxBoundField;

            if (boundField != null && String.Compare(boundField.DataField, name, true) == 0)

                return boundField;

        }

        return null;

    }

    #endregion

Example in c# to get selected value

public void LeaveBalanceValidation(object sender, AxBoundFieldDataChangedEventArgs e)

{

string LeavetypeBalance = Convert.ToString(e.Value);

}

<dynamics:AxReferenceBoundField AutoPostBack=”True” DataField=”LeaveType”

DataSet=”LeaveBalance” DataSetView=”Mzk_LeaveHistory”

SortExpression=”LeaveType”    OnDataChanged=”LeaveBalanceValidation”>

</dynamics:AxReferenceBoundField> 

//other way around is:

I)       string date3 = Convert.ToString(this.AxDataSource1.GetDataSourceView(“Mzk_AlternativeLeave”).DataSetView.GetCurrent().GetFieldValue(“StartDate”));

II)     string stDate = (string)this.AxDataSource1.GetDataSourceView(“Mzk_AlternativeLeave”).DataSetView.GetCurrent().GetFieldValue(“StartDate”).ToString() ;

Note: It Will return the DateTime vaule from the field, so we need to convert it from string to UTC datetime and from there we need to get the date.

dateTime(utcdatetime) = str2datetime(_stDate, 213); 

    _startDate(date) = DateTimeUtil::date(dateTime);

To assign value to bound field

DataSetViewRow row;

row = AxDataSource1.GetDataSet().DataSetViews[“Mzk_LeaveHistory”].GetCurrent();

row.BeginEdit();

row.SetFieldValue(“TmpLeaveBalance”, Convert.ToDouble(yeartoDate));

row.SetFieldValue(“NoofWorkingDays”, Convert.ToDouble(yeartoEnd));

row.EndEdit();

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s