Eppiey
Eppiey

Reputation: 95

Label showing "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); 

i use that particular code to calculate the percentage and to assign the percentage value to a label. however, when running it, it displays "System.Web.UI.WebControls.Label" instead of the value.

for your information: i use

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

but this time it works just fine. i'm stucked.

Upvotes: 0

Views: 1796

Answers (1)

Curtis
Curtis

Reputation: 103348

It should be:

peratusELabel.Text = String.Format("{0:0.00}", peratusE); 

In your first code block you are formatting a Label object, not a double object.

Upvotes: 2

Related Questions