在gridview内部计算列值. [英] Inside gridview calculate column value.

查看:69
本文介绍了在gridview内部计算列值.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在网格视图中计算两列,而计算应该在第三列中.
我根据
获得了数据库中的项目比率和用户输入的数量 两列都进行计算并以第三列的量显示.

当用户在数量相同的时间数量栏中显示值时,可以计算出比率和数量.

谢谢


我的功能是

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();

               //For calculate item Amount....
               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???

推荐答案

find(txtqty); var lbl_Rate =
find(txtqty); var lbl_Rate =


find(labelrate) var lbl_Amount =
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 >
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();

               //For calculate item Amount....
               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???


这篇关于在gridview内部计算列值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆