newbie - how to reference index for datalist record

S

Steve

I am using a datalist to display a number of records.

Each record has a unique id (RecordID field), which I have set as the
DataKeyField for the datalist.

In the Item Template of the datalist, I have added a button. I want to
be able to retrieve the RecordID of the relevant record when the button
for the record is clicked by the user.

i.e. I want to somehow specify for the click event of the button that
RecordID = the RecordID of the record, whose button was just clicked!

I know I have to use the index property, but I have become confused as
to how to do this.

I tried:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)

Dim RecordID As Integer
id = DataList1.DataKeys(e.item.FindControl("RecordID"))

End Sub

But I get the error message:

Error 'item' is not a member of 'System.EventArgs'.

Can somebody help?
 

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,774
Messages
2,569,598
Members
45,161
Latest member
GertrudeMa
Top