Hi,
I want to calculate two column inside grid-view and calculation should come in third column.
i have rate of item from database and user input quantity on the basis of
both column make calculation and display in third column amount.
here is it possible when user insert value in quantity same time amount column display calculation of rate and amount.
Thanks
my function is
<script type="text/javascript" language="javascript">
function show(labelrate, labelamount, txtqty) {
var txt_Quantity = $find(txtqty);
var lbl_Rate = $find(labelrate)
var lbl_Amount = $find(labelamount);
//lbl_Amount.innerHTML = parseInt(txt_Quantity.get_value()) * parseInt(lbl_Rate.get_value());
var total = txt_Quantity.Getvalue() * lbl_Rate.Getvalue();
labelamount.Setvalue(total);
}
</script>
protected void radGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem || e.Item.IsInEditMode)
{
GridDataItem item = (GridDataItem)e.Item;
DropDownList list = (DropDownList)item.FindControl("ddl1");
list.Items.Insert(0, new ListItem("select", "-1"));
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["chalk_hillConnectionString"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand("select product_name from product_detail", con);
DataSet ds = new DataSet();
da.Fill(ds);
list.DataSource = ds;
list.DataBind();
Label lbl_Rate = (Label)item.FindControl("lblRate");
TextBox txt_Quantity = (TextBox)item.FindControl("txtQuantity");
Label lbl_Amount = (Label)item.FindControl("lblAmount");
txt_Quantity.Attributes.Add("onFocusout", "return show('" + txt_Quantity.ClientID + "','" + lbl_Rate.ClientID + "','" + lbl_Amount.ClientID + "')");
lbl_Rate.Attributes.Add("onFocusout", "return show('" + txt_Quantity.ClientID + "','" + lbl_Rate.ClientID + "','" + lbl_Amount.ClientID + "')");
lbl_Amount.Attributes.Add("onFocusout", "return show('" + txt_Quantity.ClientID + "','" + lbl_Rate.ClientID + "','" + lbl_Amount.ClientID + "')");
}
}
but this is unable to make calculation???