I have nested datagrids. The master one, called Questions, is a list of ... questions. The slave grid displays X possible answers for each question. Each answer is associated to a score.
For calculating a measure, I would need to sum all the possible Mins meaning the total score if, for each question, the answer providing the lowest score would be selected. And the same for the Maxs.
The table with answers is just made of the (idT1_AnswerList), the id of the question (T1_Qref), a possible full text answer (T1_Answer) and the associated score (T1_Score). It overall looks like this:
I am struggling to get Min and Max and would love to get t it with minimum coding as it is always a long trial and error exercise for me.
My thinking is, when child data is loaded into ${result}, to execute a small loop which for each T1_QRef create a small List, determine the Min and Max of the List and add it to a variable.
Before I fight my way doing this, I just wanted to make sure it is the right way.
The way to read this is that for each Q1Ref, there are a number of possible answers, each one attached to a score.
The ultimate objective is to have 2 numeric boxes. Box1 (value sumMin) shows the summed score of all possible worst answers (-700 here) and Box2 (value sumMax) the summed score of all possible best answers (+800 here).
I get an error: 'IEnumerable' does not contain a definition for 'T1Score'. I have tried everything I could find in doc and other posts but fail to understand why T1Score is not a sub result of getT1PossibleAnswersResult.
I circled back a similar issue I had, I get that there is something more fundamental I don't get but, after 7 hours, I am lacking ideas.
I did read your response and never take it lightly. I know now what I do wrong but fail to understand what I should be doing instead. Any example you can point me to ?
Took me some time but finally got it. Thank you very much for your guidance
foreach(var answerContainer in getT1PossibleAnswersResult)
{
// check if T1Qref is first or has changed
if (currentT1Qref != answerContainer.T1Qref.Value) {
//Adds the min and max value if T1QRef has changed
sumMin = sumMin + tempMin;
sumMax = sumMax + tempMax;
// sets currentT1QRef
currentT1Qref = answerContainer.T1Qref.Value;
// sets tempMin and tempMax to first T1Score of current T1QRef
tempMin = answerContainer.T1Score.Value;
tempMax = answerContainer.T1Score.Value;
}
else {
// Changes tempMin to newest min value if relevant
if (tempMin > answerContainer.T1Score.Value) {
tempMin = answerContainer.T1Score.Value;
}
// Changes tempMax to newest max value if relevant
if (tempMax < answerContainer.T1Score.Value) {
tempMax = answerContainer.T1Score.Value;
}
}
}
// Last loop item
if (currentT1Qref >= 0) {
sumMin = sumMin + tempMin;
sumMax = sumMax + tempMax;
}