zoukankan      html  css  js  c++  java
  • 获取GridView行索引 Ver2

    前一版本http://www.cnblogs.com/insus/archive/2013/01/13/2858768.html 是用Javascript获取GridView的行索引。

    此篇Insus.NET使用非Javascript获取GridView的行索引。

    数据还是使用前一篇的数据来更改。

    首先为GridView的控件写OnRowCreated ="GridViewCosmetic_RowCreated"

     1  Protected Sub GridViewCosmetic_RowCreated(sender As Object, e As GridViewRowEventArgs)
     2         If e.Row.RowType = DataControlRowType.DataRow Then
     3             If e.Row.FindControl("LinkButton1") IsNot Nothing Then
     4                 Dim link As LinkButton = DirectCast(e.Row.FindControl("LinkButton1"), LinkButton)
     5                 AddHandler link.Click, AddressOf link_click
     6             End If
     7         End If
     8     End Sub
     9 
    10     Private Sub link_click(sender As Object, e As EventArgs)
    11         Dim link As LinkButton = DirectCast(sender, LinkButton)
    12         Dim gvr As GridViewRow = DirectCast(link.Parent.Parent, GridViewRow)
    13 
    14         Response.Write("<scr" & "ipt>alert('你选择的行索引是:" & gvr.RowIndex & "')</scr" & "ipt>")
    15     End Sub
  • 相关阅读:
    join
    PS1-4
    tftp + bras
    awk调用shell
    curl
    ssh
    查看cp进度,使用watch
    tftp
    scp 链接文件的问题 + tar
    mysql必知必会(三、使用mysql)
  • 原文地址:https://www.cnblogs.com/insus/p/2858803.html
Copyright © 2011-2022 走看看