开发者

DataKeys dataList

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 s开发者_如何转开发pecify it in DataKeyField and later on retrieve it in ondeletecommand event of DataList?

Thanks in advance :)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜