如何计算总列的percenatge并在vb.net的datagridview中显示它 [英] how to calculate percenatge on total column and display it in datagridview in vb.net

查看:63
本文介绍了如何计算总列的percenatge并在vb.net的datagridview中显示它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有1个列名amt。和数据类似(120,200,400,600等)



现在这个列我想执行求和功能。所以我得到的任何价值,我需要计算15%的百分比,这将被重命名为溢价,然后我想显示datagridview显示数据网格中的amt,totalamt和premium。



例如,如果列总数为10000,则10000 = 1500时为15%(这是溢价)



因此在datagridview中它将显示为

amt totalamt premium fulltotal

120 10000 1500 11500

200

400

600



任何人都可以帮助我。



紧急,请我全部请你。



提前感谢

i have 1 column name amt. and the data are like thes(120,200,400,600 etc)

now on this column i want to perform sum function. so whatever value i get on that i need to calculate 15% percenatge which will be renamed as premium and then i want to display it datagridview showing the amt,totalamt and premium in datagridview.

e.g if amt column total is 10000 ,thn 15% on 10000=1500(this is premium)

so in datagridview it will show as
amt totalamt premium fulltotal
120 10000 1500 11500
200
400
600

Can anyone please help me.

its urgent, please i request you all.

thanks in advance

推荐答案

通过使用gridView的RowDataBound事件解决了这个问题



For this problem solved by using RowDataBound Event of gridView

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true" OnRowDataBound="CustomersGridView_RowDataBound">
 </asp:GridView>







c#页码






c# page code

DataTable dt = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {
        dt.Columns.Add("amt", typeof(Int32));
        dt.Columns.Add("pamt", typeof(Int32));
        dt.Columns.Add("damt", typeof(Int32));
        DataRow dr=dt.NewRow();
        dr[0] = 200;
        dt.Rows.Add(dr);
        DataRow dr1 = dt.NewRow();
        dr1[0] = 400;
        dt.Rows.Add(dr1);
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }
   protected void CustomersGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            // Display the company name in italics.
            e.Row.Cells[1].Text =Convert.ToString(Convert.ToInt32(e.Row.Cells[0].Text)*15/100);
            e.Row.Cells[2].Text = Convert.ToString(Convert.ToInt32(e.Row.Cells[1].Text) * 15);
        }

    }


这篇关于如何计算总列的percenatge并在vb.net的datagridview中显示它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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