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

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
 
M

makthar

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top