Dec 03, 2007 8:39 AM
RowDeleting handler for my
GridViewDeleteEventArgs.Keys collection is empty. I'm setting the
DataKeyNames property correctly - what gives?
I found a number of posts about this issue - the DataKeys are populated by the
DataBind() but don't seem to survive postback. But they do survive the postback - they just aren't passed
GridViewDeleteEventArgs. The keys are still in the GridView itself after postback.
So instead of this:
int ID = int.Parse(((DictionaryEntry)e.Keys[e.RowIndex]).Value.ToString());
I just do this:
int ID = (int)gvSessions.DataKeys[e.RowIndex].Value;
I saw a couple of suggestions to re-bind the data right before doing the delete. This of course ignores the possibility that the data has changed. The wrong record could wind up being deleted, if you're just going by index in the GridView.
Dec 02, 2007 2:48 PM
I'm experimenting with the facebook API lately using Nikhil Kothari's Facebook.NET. The first thing I've had to do that wasn't entirely obvious from the example code was update the profile outside the context of a request.
This is a common scenario, I think - sending messages or updating the profile in response to events that happen when nobody is actually accessing the application.
First you need to have stored the facebook ID and infinite session key for the user whose information you want to update. The application key and secret are already in web.config, if you're set up the same way as the example project. So here's the code:
public class Utils
public static void UpdateProfile(string facebookID, string facebookSession)
FacebookSection section =
FacebookService service = new FacebookService(
string profileFbml = BuildProfileFbml(facebookID);
string titleFbml = " is testing stuff...";
string bodyFbml = "test";
service.Feed.PublishMiniFeedStory(titleFbml, bodyFbml, null);