您好我已经在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
答案 0 :(得分:0)
如果Aristos是对的话 将AutoPostBack设置为True
答案 1 :(得分:0)
设置SelectedIndex
属性不会触发事件,但调用SelectRow
方法会。