Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 标签上显示;System.Web.UI.WebControls.Label“;_C#_Asp.net - Fatal编程技术网

C# 标签上显示;System.Web.UI.WebControls.Label“;

C# 标签上显示;System.Web.UI.WebControls.Label“;,c#,asp.net,C#,Asp.net,我使用特定的代码来计算百分比,并将百分比值分配给标签。但是,在运行它时,它会显示“System.Web.UI.WebControls.Label”而不是值 供您参考:我使用 double peratusE = ((double)(bilanganE / calonAmbil)) * 100.00; Label peratusELabel = row.Cells[16].FindControl("peratusELabel") as Label;

我使用特定的代码来计算百分比,并将百分比值分配给标签。但是,在运行它时,它会显示“System.Web.UI.WebControls.Label”而不是值

供您参考:我使用

double peratusE = ((double)(bilanganE / calonAmbil)) * 100.00;
                    Label peratusELabel = row.Cells[16].FindControl("peratusELabel") as Label;
                    peratusELabel.Text = String.Format("{0:0.00}", peratusELabel); 
但这次效果很好。我累坏了。

应该是:

double peratusD = ((double)(bilanganD / calonAmbil)) * 100.00;
                    Label peratusDLabel = row.Cells[14].FindControl("peratusDLabel") as Label;
                    peratusDLabel.Text = String.Format("{0:0.00}", peratusD);

在您的第一个代码块中,您正在格式化一个
标签
对象,而不是一个
double
对象。

您是否尝试过单步执行代码(调试)?这可能会让你明白为什么它没有返回正确的文本没有问题:)我们都会犯错误!
peratusELabel.Text = String.Format("{0:0.00}", peratusE);