Friday 14 December 2012

Get Control in Gridview's Row command Event

<%-- Let us consider below is our grid.--%>

 
      
           
              

              
           
      
 

'Here is code behind.
Private Sub gridview_RowCommand(sender As Object, _

e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gridview.RowCommand
 
Dim btnActive As Button = DirectCast(e.CommandSource, Button)
Dim index As Integer = DirectCast(btnActive.Parent.Parent, GridViewRow).RowIndex
Dim chkmail As CheckBox = DirectCast(gridview.Rows(index).FindControl("chkmail"), CheckBox) 

'Here i get control like btnactive.parent.parent.It may be different for you.
'It depends how many controls you use in grid view. 

End Sub

No comments:

Post a Comment