tags:

views:

14

answers:

1

Hello,

This is my bare DataList definition :-

  <asp:DataList runat="server" ID="dtltrial" 
            ondeletecommand="dtltrial_DeleteCommand" DataKeyField="PhotoId" >

       </asp:DataList>

where PhotoId is my primary key of table and so i have given it as datakeyField. However i also want AlbumId along with DataKeyField. How do i specify it in DataKeyField and later on retrieve it in ondeletecommand event of DataList?

Thanks in advance :)

+1  A: 

You can specify:

DataKeyNames="PhotoId,AlbumId"

Update:

It looks like the DataList doesn't allow you to specify multiple keys, and then retreive them as normal. From this question, the accepted answer deals with a GridView. Unfortunately the DataList doesn't function the same.

You'll likely have to create a unique identifier yourself at the datasource, or create a hybrid on a databinding event. For example, "PhotoId_AlbumId", which would turn into "837_7826". On the delete event, you'd then have to extract out the two IDs, separated by the underscore.

Consider creating a new single primary key on the datasource instead.

p.campbell