trying to bind to a Datalist key
Posted on 2009-07-09
Hi all, I have a datalist as such:
<asp:DataList ID="DataList2" runat="server" BackColor="White"
BorderColor="#FFCCFF" BorderStyle="Solid" BorderWidth="2px" CellPadding="4"
GridLines="Vertical" RepeatColumns="4" RepeatDirection="Horizontal"
When I go to the code-behind, I am trying to use that DataKeyField, but can't seem to find it correctly. If I do the following I will get the first record and can go on through them one at a time, so I know it is there:
Dim MerchandiseId As String = DataList2.DataKeys(0).ToString()
But of course I only want the one I am clicking on, I would think the following would work, but I get an error, (item is not a member of system.eventArgs) can someone please tell me what small syntax I have wrong...
Dim MerchandiseId as String= DataList2.DataKeys(e.Item.ItemIndex)
I have tried using SelectedIndex and several other things, but don't seem to be able to find the correct combination.