【问题标题】:What is the difference between following code以下代码有什么区别
【发布时间】:2014-03-21 10:16:18
【问题描述】:
var id = Convert.ToInt32(GridViewVehicleList.DataKeys[e.NewSelectedIndex].Value);
var id2 = Convert.ToInt32(GridViewVehicleList.DataKeys[e.NewSelectedIndex].Values);

如果我使用第二个代码作为

id2 = Convert.ToInt32(GridViewVehicleList.DataKeys[e.NewSelectedIndex].Values[1]);

,我可以将第二个 DataKey 分配给变量 id2

感谢大家的关注

【问题讨论】:

  • 阅读Docs
  • 是的,你可以。你是对的。

标签: asp.net gridview datakey


【解决方案1】:

DataKey Properties

价值

Gets the value of the key field at index 0 in the DataKey object.

价值观

Gets an IOrderedDictionary object that contains every key field in the DataKey 
object.

所以你可以分配

id2 = Convert.ToInt32(GridViewVehicleList.DataKeys[e.NewSelectedIndex].Values[1]);

【讨论】:

    猜你喜欢
    • 2013-12-03
    • 2019-09-11
    • 1970-01-01
    • 2013-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多