ascx.cs中的Eval问题 [英] Problem with Eval in ascx.cs

查看:127
本文介绍了ascx.cs中的Eval问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ascx文件中-前面的代码

In ascx file - code in front

<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" />



这会根据下拉菜单的结果产生值0 1 2 3
我正在尝试设置asp标签的文本值,以根据函数funcGetEvidenceStatus 产生的不同数值显示不同的文本消息.如果我在前面的代码中包含该函数,则会得到正确的数字,但是当我尝试从Eval 陈述(int)Eval("eviID")遇到问题时更改后面的代码,我如何从后面的代码中删除Eval 的任何想法


在背后的代码中



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

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";
 }



我已经尝试过DataItem和Container.DataItem,但没有任何乐趣-有什么想法吗?我是VB更好的C#初学者!



I''ve tried DataItem and Container.DataItem but no joy - any ideas? I''m new to C# better with VB!

推荐答案

您从哪里获得Eval的?为什么不能这样缩短代码:
Where did you get Eval from? And why can''t you shorten your code like this:
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.


这篇关于ascx.cs中的Eval问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆