How can I display an integer in a Label? What I am doing is I am calculating the total and I am trying to display it in a label.
public partial class total : System.Web.UI.Page
{
int total;
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Server.HtmlEncode(Request.Cookies["confirm"]["quantity"]);
int quantity = (int)Session["TextBox1Value"];
if (Request.Cookies["user"]["items"] == "Tyres")
{
total = 20 * quantity;
Label2.Text = ???
}
}
}
Or is there any other way to display the total on same page?
Use
OR
Since
Texttakes a string so you have to convert yourtotalinteger value to string by callingToString()orConvert.ToString(int).