Thursday, April 14, 2011

To get the commandargument in rowdatabound event in gridview

hi guys, Following is code for buttonclick in gridview.

Protected Sub lnkChangeStatus_Click(ByVal sender As Object, ByVal e As EventArgs) 

    Dim gvr As GridViewRow = TryCast(DirectCast(sender, LinkButton).Parent.Parent, GridViewRow) 

    Dim lngProfileId As Long = Convert.ToInt64(gvwBusinessProfiles.DataKeys(gvr.RowIndex).Value) 

End Sub

I want to get commandargument of lnkChangeStatus in its click.Is there any way

From stackoverflow
  • I guess the syntax for the eventhandler (Command event as against Click) should be as below.

    
    Protected Sub lnkChangeStatus_Command(ByVal sender As Object, ByVal e As CommandEventArgs) 
    .....
    
    End Sub
    

    You can use e.CommandName or e.CommandArgument inside the code block.
    Refer this

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.