【问题标题】:Getting the index of a row in Asp.net Gridview在 Asp.net Gridview 中获取行的索引
【发布时间】:2009-03-17 07:56:53
【问题描述】:

我已经使用了这个代码。它显示一个错误: 暗淡的行 As GridViewRow = CType(CType(e.CommandSource, Control).NamingContainer, GridViewRow)

报错如下:

FFK.DLL 中出现“System.InvalidCastException”类型的异常,但未在用户代码中处理

附加信息:无法将“System.Web.UI.WebControls.ContentPlaceHolder”类型的对象转换为“System.Web.UI.WebControls.GridViewRow”类型。

【问题讨论】:

    标签: vb.net


    【解决方案1】:

    我假设你想要的是 GridView 的 selected 行的索引?

    如果是这样,您可以尝试以下方法:

    Me.GridView1.SelectedIndex
    

    ...这将为您提供 GridView 中行的从零开始的索引位置。

    希望这会有所帮助,

    【讨论】:

    • IE您可以这样做:将行设为 GridViewRow = Me.GridView1.Rows(Me.GridView1.SelectedIndex)
    猜你喜欢
    • 2016-10-11
    • 2023-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-03
    • 1970-01-01
    • 2018-10-28
    • 1970-01-01
    相关资源
    最近更新 更多