Hello
I have taken 4 epitextbox called Breath.txt , Length.txt,Height.Txt & Volume.txt. User will input value for length,breath,height and get an Auto Generated Calculated Value in Volume.txt. This Calculated Value does not hold if I Bind with UD Field. So how can hold this value After epibinding.
learn embedded customisation.
haso have briefed about it nicely.
Don’t set the value to the TextBox and don’t reference the TextBox values. Use the EpiDataViews instead.
Hello
Am not able to insert data into UD01 table using Epidataview. Using below c# code…so let me know where am missing.Thanks in advance.
private void epiButtonC1_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
EpiDataView edv = (EpiDataView)oTrans.EpiDataViews[“UD01”];
edv.dataView[edv.Row][“Key1”]= epiTextBoxC1.Text;
edv.dataView[edv.Row][“Character01”]= epiComboC1.Text;
edv.dataView[edv.Row][“Character02”]= epiTextBoxC2.Text;
edv.dataView[edv.Row][“Character03”]= epiTextBoxC3.Text;
edv.dataView[edv.Row][“Character04”]= epiTextBoxC4.Text ;
edv.dataView[edv.Row][“Character05”]= epiComboC2.Text;
edv.dataView[edv.Row][“Key2”]= epiComboC3.Text;;
oTrans.Update();
oTrans.Refresh();
}
On button press, calculate the value for the Volume, but don’t update the control.
Instead, write that value to the DB field bound to the control.
Edit
Which form are you trying to do this in?
thank you for your response
I have taken a new UD01 form .where am using epidataview to store data.
You are still using the Text Boxes. Why? If it is unclear at this point, I would highly encourage you to read the post from @hkeric.wci above.
You don’t need to update the data view.
Just have your button calculate the volume and update the control that is bound to it.
It will get written to the DB when the record is saved.
Also, you should:
- Store the values in Numberxx fields not Characterxx fields
- Make your L, W, and H controls to be numericEditors
- Make the control for the calculated Volume value be read only.
A feature enhancement would be to recalc the volume using OnChange events for the L, W, and H controls. Then it automatically updates if any of theses three are changed.
The post above is not exactly right.
Here’s the code I came up with
private void btnCalcVolume_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
updateVolume();
}
private void numHeight_TextChanged(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
updateVolume();
}
private void numLength_TextChanged(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
updateVolume();
}
private void numWidth_TextChanged(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
updateVolume();
}
private void updateVolume(){
decimal volume=0;
volume = (decimal)numWidth.Value * (decimal)numLength.Value * (decimal)numHeight.Value;
numVolume.Value = volume;
/***
EpiTextBox key1 = (EpiTextBox)csm.GetNativeControlReference("46567b2e-6bc0-4967-be35-a0ec6843838f");
EpiTextBox key2 = (EpiTextBox)csm.GetNativeControlReference("5feb5781-48c2-440b-845e-019bd6d897f3");
EpiTextBox key3 = (EpiTextBox)csm.GetNativeControlReference("270f2a33-fb54-4f81-87eb-b76ea1c88653");
EpiTextBox key4 = (EpiTextBox)csm.GetNativeControlReference("2a1d9451-d277-48be-92f6-abca977cde0c");
EpiTextBox key5 = (EpiTextBox)csm.GetNativeControlReference("a6a32ec0-bc92-48cd-a6c0-7455927bf4aa");
****/
EpiDataView edv = (EpiDataView)oTrans.EpiDataViews["UD01"];
/*****
edv.dataView[edv.Row]["Key1"]= key1.Value;
edv.dataView[edv.Row]["Key2"]= key2.Value;
edv.dataView[edv.Row]["Key3"]= key3.Value;
edv.dataView[edv.Row]["Key4"]= key4.Value;
edv.dataView[edv.Row]["Key5"]= key5.Value;
edv.dataView[edv.Row]["Number01"]= numWidth.Value;
edv.dataView[edv.Row]["Number02"]= numLength.Value;
edv.dataView[edv.Row]["Number03"]= numHeight.Value;
******/
edv.dataView[edv.Row]["Number04"]= (decimal)numVolume.Value;
oTrans.Update();
oTrans.Refresh();
}
It uses 4 numEditor controls, and the _TextChanged event of each of the three inputs.
Only the changed value needs to be written to the edv. Don’t need to set the Key fields either.
Thank you for your response
I tried the same code which you have shared.but there is some issue , the value is showing in Volume numEditor but on button double click .And numVolume.Value is also not storing in UD01 Table. i followed the same steps which you told. so let me know where am missing.
Yeah… Not sure what we’re doing wrong.
I’ve added a bunch of message boxes for debugging, and can see the values of the edv members at various stages.
Here it is right before calling oTrans.Update();

And here it is right after

Number04 returns to the value it was when the record was loaded.
Try a BeginEdit() and EndEdit().
Okay … The following appears to work (I left in all the debugging messages)
Function called by btnCalcVolume_Click()
private void updateVolume(){
decimal volume=0;
string message="";
EpiDataView edv = (EpiDataView)oTrans.EpiDataViews["UD01"];
var row = edv.CurrentDataRow;
message =" After edv declared\n";
message += "Number01: " + edv.dataView[edv.Row]["Number01"].ToString() + "\n";
message += "Number02: " + edv.dataView[edv.Row]["Number02"].ToString() + "\n";
message += "Number03: " + edv.dataView[edv.Row]["Number03"].ToString() + "\n";
message += "Number04: " + edv.dataView[edv.Row]["Number04"].ToString() + "\n";
message += "RowMod: " + edv.dataView[edv.Row]["RowMod"];
MessageBox.Show(message);
message = "Width: " + numWidth.Value + "\n";
message += "Length: " + numLength.Value + "\n";
message += "Height: " + numHeight.Value + "\n";
volume = (decimal)numWidth.Value * (decimal)numLength.Value * (decimal)numHeight.Value;
numVolume.Value = volume;
message += "\nVolume: " + volume.ToString();
MessageBox.Show(message);
EpiTextBox key1 = (EpiTextBox)csm.GetNativeControlReference("46567b2e-6bc0-4967-be35-a0ec6843838f");
EpiTextBox key2 = (EpiTextBox)csm.GetNativeControlReference("5feb5781-48c2-440b-845e-019bd6d897f3");
EpiTextBox key3 = (EpiTextBox)csm.GetNativeControlReference("270f2a33-fb54-4f81-87eb-b76ea1c88653");
EpiTextBox key4 = (EpiTextBox)csm.GetNativeControlReference("2a1d9451-d277-48be-92f6-abca977cde0c");
EpiTextBox key5 = (EpiTextBox)csm.GetNativeControlReference("a6a32ec0-bc92-48cd-a6c0-7455927bf4aa");
edv.dataView[edv.Row]["Company"]= "MC";
edv.dataView[edv.Row]["Key1"]= key1.Value;
//edv.dataView[edv.Row]["Key2"]= key2.Value;
//edv.dataView[edv.Row]["Key3"]= key3.Value;
//edv.dataView[edv.Row]["Key4"]= key4.Value;
//edv.dataView[edv.Row]["Key5"]= key5.Value;
edv.dataView[edv.Row].BeginEdit();
edv.dataView[edv.Row]["Number01"]= numWidth.Value;
edv.dataView[edv.Row]["Number02"]= numLength.Value;
edv.dataView[edv.Row]["Number03"]= numHeight.Value;
edv.dataView[edv.Row]["Number04"]= numVolume.Value;
edv.dataView[edv.Row]["RowMod"]= "U";
edv.dataView[edv.Row].EndEdit();
message =" After setting edv members, and before Update()\n";
message += "Number01: " + edv.dataView[edv.Row]["Number01"].ToString() + "\n";
message += "Number02: " + edv.dataView[edv.Row]["Number02"].ToString() + "\n";
message += "Number03: " + edv.dataView[edv.Row]["Number03"].ToString() + "\n";
message += "Number04: " + edv.dataView[edv.Row]["Number04"].ToString() + "\n";
message += "RowMod: " + edv.dataView[edv.Row]["RowMod"];
MessageBox.Show(message);
oTrans.Update();
message =" After edv oTrans.Update\n";
message += "Number01: " + edv.dataView[edv.Row]["Number01"].ToString() + "\n";
message += "Number02: " + edv.dataView[edv.Row]["Number02"].ToString() + "\n";
message += "Number03: " + edv.dataView[edv.Row]["Number03"].ToString() + "\n";
message += "Number04: " + edv.dataView[edv.Row]["Number04"].ToString() + "\n";
message += "RowMod: " + edv.dataView[edv.Row]["RowMod"];
MessageBox.Show(message);
oTrans.Refresh();
message =" After edv oTrans.Refresh\n";
message += "Number01: " + edv.dataView[edv.Row]["Number01"].ToString() + "\n";
message += "Number02: " + edv.dataView[edv.Row]["Number02"].ToString() + "\n";
message += "Number03: " + edv.dataView[edv.Row]["Number03"].ToString() + "\n";
message += "Number04: " + edv.dataView[edv.Row]["Number04"].ToString() + "\n";
message += "RowMod: " + edv.dataView[edv.Row]["RowMod"];
MessageBox.Show(message);
}
@dhewi - Is setting edv.dataView[edv.Row]["RowMod"]= "U"; required when using the BeginEdit() and EndEdit() ??
As far as I understand it, that’s pretty much what using those does. I haven’t found you need both, but I’m always ready to be proved wrong (just as well, since it happens regularly).
What fooled me for a long time was that so often when you make a change to a dataview there’s already a change that’s triggered what you’re doing, so the row is already marked as needing an update. It’s cases like these where you’re making the first and only change where you need to make sure the dataview “knows” it’s been edited.
Thank for your response
now its working