How to multiply two column values in GridView in ASP.Net

Last Reply on Nov 19, 2014 12:19 AM By abdeali

Posted on Nov 18, 2014 10:23 PM

Hi,

How To Multiply TwO  Values In GridView In asp.net using c#

 

Thank You

You are viewing reply posted by: abdeali on Nov 19, 2014 12:19 AM.
Posted on Nov 19, 2014 12:19 AM

Add row data bound event

protected void gdv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
   if (e.Row.RowType == DataControlRowType.DataRow)
   {
      Label lblcost = (Label)e.Row.FindControl("lblcost");
      int cost = Convert.ToInt16(lblcost.Text);
      TextBox txtquantity = (TextBox)e.Row.FindControl("txtquantity");
      int quant = Convert.ToInt16(txtquantity.Text);
      int Prize = cost * quant;
      Label lbTotal = (Label)e.Row.FindControl("lbTotal");
      lbTotal.Text = Prize.ToString();

    }
}