<p>I have a datalist with a OnDeleteCommand="Delete_Command".</p>

<p>I want the delete a record with multiple primary Keys but I do not know how to access it from the Delete_Command event.</p>

<p>If I use DataKeyField I'm limited to only one key.
Any workarounds for this?</p>

[{'answer_id': 19447, 'author': 'Biri', 'author_id': 968, 'author_profile': 'https://Stackoverflow.com/users/968', 'pm_score': 2, 'selected': True, 'text': '<p>You can access all of the keys:</p>\n\n<pre><code>gridView.DataKeys[rowNum][dataKeyName]\n</code></pre>\n\n<p>where rowNum is e.RowIndex from the gridView_RowDeleting event handler, and dataKeyName is the key you want to get:</p>\n\n<pre><code>&lt;asp:GridView ID="gridView" runat="server" DataKeyNames="userid, id1, id2, id3" OnRowDeleting="gridView_RowDeleting"&gt;\n\nprotected void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e)\n{\n    gridView.DataKeys[e.RowIndex]["userid"]...\n    gridView.DataKeys[e.RowIndex]["id1"]...\n    gridView.DataKeys[e.RowIndex]["id2"]...\n    gridView.DataKeys[e.RowIndex]["id3"]...\n}\n</code></pre>\n'}, {'answer_id': 19513, 'author': 'Biri', 'author_id': 968, 'author_profile': 'https://Stackoverflow.com/users/968', 'pm_score': 0, 'selected': False, 'text': '<p>Oh, sorry, I missed it.</p>\n\n<p>AFAIK there is no such a possibility by default. Maybe you can create a composite key from your primary keys, like </p>\n\n<blockquote>\n  <p>Key1UnderscoreKey2UnderscoreKey3</p>\n</blockquote>\n\n<p>and split it in the event handler. So this is a DIY multi-key handler for DataList :-)</p>\n\n<p>Edit: The underscore got lost during format, it replaces with italic text. So instead of "underscore" word use real underscores</p>\n'}]
['https://Stackoverflow.com/questions/19436', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1013/']