tags:

views:

195

answers:

1

i have used this code.and it shows an error: Dim row As GridViewRow = CType(CType(e.CommandSource, Control).NamingContainer, GridViewRow)

The error is as folows:

An exception of type 'System.InvalidCastException' occurred in FFK.DLL but was not handled in user code

Additional information: Unable to cast object of type 'System.Web.UI.WebControls.ContentPlaceHolder' to type 'System.Web.UI.WebControls.GridViewRow'.

A: 

Hi,

I am assuming that what you want is the index of the selected row of a GridView?

If so, you can try something like:

Me.GridView1.SelectedIndex

... This will give you the zero-based index position of the row in the GridView.

Hope this helps,

/Richard.

Richard
I.E. You could do:Dim row as GridViewRow = Me.GridView1.Rows(Me.GridView1.SelectedIndex)
Richard