ASP.Net GridView GridViewDeleteEventArgs.Keys empty

Posted by the berserker on Stack Overflow See other posts from Stack Overflow or by the berserker
Published on 2009-09-09T08:52:07Z Indexed on 2010/06/11 15:52 UTC
Read the original article Hit count: 466

Filed under:
|

I have following Gridview:

<asp:GridView ID="GridView1" runat="server" CssClass="table" DataKeyNames="groupId"
          DataSource="<%# dsUserGroupsSelected %>" DataMember="Group" etc....>

and after firing RowDeleting event handler:

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)

e.Keys is empty. Moreover, in runtime if I check

dsUserGroupsSelected.Group.PrimaryKey

it is poulated with:

{System.Data.DataColumn[1]}
    [0]: {groupId}

so it's really odd to me. Am I missing something? I have this kind of a workaround:

int groupId = (int)GridView1.DataKeys[e.RowIndex].Value;

which will work just fine, but I just can't get it why e.Keys (and e.Values) would be empty!? Any ideas?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about gridview