Getting the data key field value when selecting a row in a datagrid...

  • Thread starter Thread starter Stu
  • Start date Start date
S

Stu

Hi,

I am trying to return the data key field value from a dataset when I select
a row in a datagrid after the datagrid has been bound to a dataset.

When I an the Edit, Update and Cancel row I can return the DataKey using the
sub listed below. However, the select button does not have
'DataGridCommandEventArgs' as one of it's parameters so I cannot use the
same command.

-----------
Public Sub UpdateCommand(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.UpdateCommand
Response.Write("The datakey for this row is:" &
DataGrid1.DataKeys(e.Item.ItemIndex).ToString)
End Sub
-----------

Anybody any ideas?

Thanks in advance,

Stu
 
You can get the data key value from the ItemCommand event
when a user clicks on the datagrid select button. Then
use this value to do whatever you want.
 
Back
Top