Geeks With Blogs
Create Fun Things - Samer's Developer Blog Development Blog for C#, .NET and Obj-C

Just a quick tip this morning. I have a TimeSheet program I wrote that I recently overhauled with new controls and databinding, etc. I have a ListView in it that displays all my time records in a paged format, and also allows me to delete entries.

However, whenever I clicked “delete”, the page would just postback to itself and nothing would change. There were no exceptions or anything, so it was a bit of a head scratcher. I had this problem once before a long time back, and it turned out that my CommandName was set incorrectly—but in this case it correctly said “CommandName=”Delete”” so it couldn’t have been that.

Turns out I forgot to write in the “DataKeyNames” for the ListView, that would effectively pass back the required parts of my business object to delete it. (In my case, the primary key and the timestamp column.)

I added in “DataKeyNames=”TimeRecordID_PK, Version”” and it now the delete works as it should.


Samer Paul

Posted on Wednesday, August 26, 2009 8:51 AM Quick Tips | Back to top

Comments on this post: Quick Tip: Check DataKeyNames in ListView If Events are Failing

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © samerpaul | Powered by: