Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In ascx file - code in front
XML
<asp:Label ID="lblKPIStatus" Text='<%# ((int)AchievementQualityMark.AQMFunctions.funcGetEvidence_Status((int)AchievementQualityMark.AQMFunctions.funcGetEvidence_ID(Convert.ToInt32((string)hdnAuditID.Value), Convert.ToInt32((string)hdnKPIID.Value), (int)Eval("eviID"))))%> ' runat="server" />


This produces values 0 1 2 3 based on the result from a drop down menu
I'm trying to set the text value of an asp label to display different text messages based on the different numeric values produced by the function funcGetEvidenceStatus if I include the function in the code in front I get the right numbers but when I try to alter from the code behind I have problems with the Eval statement (int)Eval("eviID") any ideas how I can eliminate the Eval from the code behind


In Code Behind
C#
if (((int)AchievementQualityMark.AQMFunctions.funcGetEvidence_Status((int)AchievementQualityMark.AQMFunctions.funcGetEvidence_ID(Convert.ToInt32((string)hdnAuditID.Value), Convert.ToInt32((string)hdnKPIID.Value), (int)Eval("eviID")))) == 0)
 {
     lblKPIStatus.Text = "None";
 }
if (((int)AchievementQualityMark.AQMFunctions.funcGetEvidence_Status((int)AchievementQualityMark.AQMFunctions.funcGetEvidence_ID(Convert.ToInt32((string)hdnAuditID.Value), Convert.ToInt32((string)hdnKPIID.Value), (int)Eval("eviID")))) == 1)
 {
     lblKPIStatus.Text = "Not In Place";
 }
if (((int)AchievementQualityMark.AQMFunctions.funcGetEvidence_Status((int)AchievementQualityMark.AQMFunctions.funcGetEvidence_ID(Convert.ToInt32((string)hdnAuditID.Value), Convert.ToInt32((string)hdnKPIID.Value), (int)Eval("eviID")))) == 2)
 {
     lblKPIStatus.Text = "Partly In Place";
 }
if (((int)AchievementQualityMark.AQMFunctions.funcGetEvidence_Status((int)AchievementQualityMark.AQMFunctions.funcGetEvidence_ID(Convert.ToInt32((string)hdnAuditID.Value), Convert.ToInt32((string)hdnKPIID.Value), (int)Eval("eviID")))) == 3)
 {
     lblKPIStatus.Text = "Fully In Place";
 }


I've tried DataItem and Container.DataItem but no joy - any ideas? I'm new to C# better with VB!
Posted
Updated 26-Jul-11 3:20am
v2
Comments
[no name] 26-Jul-11 9:17am    
Format your code using the code block.
Richard Andrews 26-Jul-11 10:00am    
Hi Shameel, Thanks for getting back to me so quickly by code block I presume you mean <script> tags in the code in from and nest my Ifs in a case statement there, I'll give it a go
[no name] 26-Jul-11 15:17pm    
No, I asked you to format your code using the CP editor to make it readable. I did not suggest any solution to your problem.
Richard Andrews 27-Jul-11 4:50am    
Hi Shameel, Thanks for the solution, I've implemented the 'case' solution in the aspx and it works fine, I'd inherited this particuler project from another programmer and have been trying to get my head round the code, thanks again for helping me over this particuler hurdle

1 solution

Where did you get Eval from? And why can't you shorten your code like this:
C#
int KPIID = Convert.ToInt32((string)hdnKPIID.Value);
int eviID = (int)Eval("eviID");
int evidenceID = (int)AchievementQualityMark.AQMFunctions.funcGetEvidence_ID(Convert.ToInt32((string)hdnAuditID.Value, KPIID, eviID);
int evidenceStatus = (int)AchievementQualityMark.AQMFunctions.funcGetEvidence_Status(evidenceID);

switch(evidenceStatus) {
    case 0:
        lblKPIStatus.Text = "None";
        break;
    case 1:
        lblKPIStatus.Text = "Not In Place";
        break;
    case 2:
        lblKPIStatus.Text = "Partly In Place";
        break;
    case 3:
        lblKPIStatus.Text = "Fully In Place";
        break;
}


Post further questions as comments to this answer.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900