嗨,我已经在 GridView 上编写了这个扩展方法。更改所选索引后,我希望触发 SelectedIndexChanged 事件。但是,这并没有发生。有什么特别的原因吗?我怎样才能解决这个问题?
<Extension()>
Public Sub SelectRowByCallId(ByVal gridviewObj As GridView, ByVal callId As String)
Dim selectedIndex As Int32 = 0
Dim pageIndex As Int32 = 0
Dim gridViewPages As Int32 = gridviewObj.PageCount
For index = 0 To gridViewPages
gridviewObj.PageIndex = index
gridviewObj.DataBind()
For i = 0 To gridviewObj.DataKeys.Count - 1
If (Convert.ToString(gridviewObj.DataKeys(i).Value) = callId) Then
selectedIndex = i
pageIndex = index
Exit For
End If
Next i
Next index
gridviewObj.PageIndex = pageIndex
gridviewObj.SelectedIndex = selectedIndex
gridviewObj.DataBind()
End Sub