asp.net - 我如何将链接按钮 oncommand 事件挂钩到另一种方法,比如 gridview OnPageIndexChanging 事件
问题描述
我有一个LinkButton
处理Command
事件的地方。我也有一个GridView
我正在处理PageIndexChanging
事件的地方。我想从' 处理程序中调用LinkButton
'Command
处理程序。我该怎么做呢?GridView
PageIndexChanging
//Code-behind of my LinkButton Command handler
Protected Sub Linkprodcat1_Command(sender As Object, e As CommandEventArgs)
If e.CommandName = "select" Then
//do something
End if
End Sub
//Code-behind of my GridView PageIndexChanging handler
//Here I want to call the the LinkButton's Command handler method
Protected Sub GridView1_PageIndexChanging(sender As Object, e As GridViewPageEventArgs)
If Me.pageindexselctoption.Value = "product1" Then
Call Linkprodcat1_Command(sender, e) //this does not work
End If
End Sub
解决方案
Call Linkprodcat1_Command(sender, e)
行不通,因为e
这里是 type GridViewPageEventArgs
。Linkprodcat1_Command
期望其第二个参数为 by 类型CommandEventArgs
。
这是我的做法:
Protected Sub Linkprodcat1_Command(sender As Object, e As CommandEventArgs)
If e.CommandName = "select" Then
SelectCommand()
End If
End Sub
Protected Sub GridView1_PageIndexChanging(sender As Object, e As GridViewPageEventArgs)
If Me.pageindexselctoption.Value = "product1" Then
SelectCommand()
End If
End Sub
Protected Sub SelectCommand()
'Do something
End Sub
推荐阅读
- php - 十月 CMS 会议中断?
- elixir - phoenix http://0.0.0.0:4000 css 未加载
- javascript - 如何在一个框中而不是多个框中提醒变量的每个部分的值?
- centos7 - Freeradius 远程数据库
- html - 我网站中的 CSS 对于某些元素不能正常工作,但它在我的其他具有相同元素的页面上工作正常
- macos - `which` 因符号链接而失败
- angular - 角材料表单元格数据包装
- wso2 - WSO2 - API Manager 模板参数中的星号
- regex - 为什么第一个字母在正则表达式中匹配
- angular - spa.UseAngularCliServer() 中间件如何为网页提供服务?