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

时间:2016-03-18 19:50:50

标签: asp.net gridview variable-assignment

我不知道如何将一个变量(newvalue)分配给GridView表的列:<asp:BoundField DataField="convertedValue" DataFormatString="{0:n2}" HeaderText="Value in" ReadOnly="True" SortExpression="convertedValue" />

,提供的代码是:

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!

谢谢!

1 个答案:

答案 0 :(得分:0)

如果您的网格绑定到dtSecurityHolding,那么您应该将值设置为:

 row["convertedValue"] = newvalue;
相关问题