I am having a problem with data type conversion that I just can figure out
HiddenField hfFriendId = item.FindControl("hfFriendId") as HiddenField;
Int32 FriendId = Convert.ToInt32(hfFriendId.Value);
I need to use FriendId as and int32 in the following
UserInfo TargetUser = UserController.GetUserById(PortalSettings.PortalId, FriendId);
as both args are expected to be int32.
When I debug this ‘TargetUser’ is null.
What might the problem be?
If you are not sure of the value available in the hiddenfield then instead of using
Try
or Better
Also it could be an issue with your
UserController.GetUserByIdmethod in case the Convert gets the value parsed and is not returning zero.