我不知道如何将一个变量(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!
谢谢!
答案 0 :(得分:0)
如果您的网格绑定到dtSecurityHolding,那么您应该将值设置为:
row["convertedValue"] = newvalue;