gridview行索引获取方法及实现代码(非js版)
程序员文章站
2024-03-04 17:10:59
前一版本是用javascript获取gridview的行索引。此篇insus.net使用非javascript获取gridview的行索引。 数据还是使用前一篇的数据来更改...
前一版本是用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
上一篇: Android获取手机联系人信息