I am creating an asp.net web application integrated with Facebook. I am trying to fetch the Friends of the logged in user in a grid view in my application.
Code:
IList<user> usrFrnds = api.Users.GetInfo(myFrndId);
Friends = usrFrnds;
// Bind to GridView to display
grvMyFriends.DataSource = Friends;
grvMyFriends.DataBind();
For example a user has two friends.
When Breakpoints hits
grvMyFriends.DataSource = Friends;
It shows count= 2
But when breakpoint comes to
grvMyFriends.DataBind();
then in immediate window it shows
Expression has been evaluated and has no value
I am not understanding where is the problem.
Any help is appreciated.
Thanks,
Isha
To bind grid you need a list. Friend is a object not list . That's why you get this error.
Try this :
IList<user> usrFrnds = api.Users.GetInfo(myFrndId);
// Bind to GridView to display
grvMyFriends.DataSource = usrFrnds;
grvMyFriends.DataBind();
Try to check if usrFrnds retrieve records.
if(usrFrnds.Count > 0 )
{
//DATA FOUND!
grvMyFriends.DataSource = usrFrnds.ToList();
grvMyFriends.DataBind();
}
else
{
//NO DATA FOUND!
}
Regards
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.