gridview行索引获取方法及实现代码(非js版)
更新时间:2013年01月14日 10:45:21 作者:
前一篇是用Javascript获取GridView的行索引,此篇Insus.NET使用非Javascript获取GridView的行索引,感兴趣的朋友可以了解下
前一版本https://www.jb51.net/article/33251.htm是用Javascript获取GridView的行索引。
此篇Insus.NET使用非Javascript获取GridView的行索引。
数据还是使用前一篇的数据来更改。
首先为GridView的控件写OnRowCreated ="GridViewCosmetic_RowCreated"
Protected Sub GridViewCosmetic_RowCreated(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.FindControl("LinkButton1") IsNot Nothing Then
Dim link As LinkButton = DirectCast(e.Row.FindControl("LinkButton1"), LinkButton)
AddHandler link.Click, AddressOf link_click
End If
End If
End Sub
Private Sub link_click(sender As Object, e As EventArgs)
Dim link As LinkButton = DirectCast(sender, LinkButton)
Dim gvr As GridViewRow = DirectCast(link.Parent.Parent, GridViewRow)
Response.Write("<scr" & "ipt>alert('你选择的行索引是:" & gvr.RowIndex & "')</scr" & "ipt>")
End Sub
此篇Insus.NET使用非Javascript获取GridView的行索引。
数据还是使用前一篇的数据来更改。
首先为GridView的控件写OnRowCreated ="GridViewCosmetic_RowCreated"
复制代码 代码如下:
Protected Sub GridViewCosmetic_RowCreated(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.FindControl("LinkButton1") IsNot Nothing Then
Dim link As LinkButton = DirectCast(e.Row.FindControl("LinkButton1"), LinkButton)
AddHandler link.Click, AddressOf link_click
End If
End If
End Sub
Private Sub link_click(sender As Object, e As EventArgs)
Dim link As LinkButton = DirectCast(sender, LinkButton)
Dim gvr As GridViewRow = DirectCast(link.Parent.Parent, GridViewRow)
Response.Write("<scr" & "ipt>alert('你选择的行索引是:" & gvr.RowIndex & "')</scr" & "ipt>")
End Sub
相关文章
asp.net下用Aspose.Words for .NET动态生成word文档中的数据表格的方法
导出word 文档,要求这个文档的格式不是固定的,用户可以随便的调整,导出内容中的数据表格列是动态的,例如要求导出姓名和性别,你就要导出这两列的数据,而且这个文档不是导出来之后再调整而是导出来后已经是调整过了的。2010-04-04ASP.NET Core使用AutoMapper实现实体映射
本文详细讲解了ASP.NET Core使用AutoMapper实现实体映射的方法,文中通过示例代码介绍的非常详细。对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2022-03-03把jQuery的each(callback)方法移植到c#中
jQuery中使用each(callback)方法可以很方便的遍历集合,如2008-03-03解决在Web.config或App.config中添加自定义配置的方法详解
本篇文章是对在Web.config或App.config中添加自定义配置的方法进行了详细的分析介绍,需要的朋友参考下2013-05-05
最新评论