我想给ASP.Net的gridview列分配一个变量

我想给ASP.Net的gridview列分配一个变量,asp.net,gridview,variable-assignment,Asp.net,Gridview,Variable Assignment,我不知道如何将一个变量(newvalue)分配给GridView表的列: 提供的代码是: foreach (DataRow row in dtSecurityHolding.Rows){ int shares = myHKeInvestCode.getColumnIndexByName(gvSecurityHolding, "shares"); int price = myHKeInvestCode.getColumnIndexBy

我不知道如何将一个变量(newvalue)分配给GridView表的列:

提供的代码是:

foreach (DataRow row in dtSecurityHolding.Rows){
                int shares = myHKeInvestCode.getColumnIndexByName(gvSecurityHolding, "shares");
                int price = myHKeInvestCode.getColumnIndexByName(gvSecurityHolding, "price");

                int newvalue = myHKeInvestCode.getColumnIndexByName(gvSecurityHolding, "value");
                newvalue = shares * price;

                // Add your code here!

谢谢

如果您的网格绑定到dtSecurityHolding,则应将值如下所示:

 row["convertedValue"] = newvalue;