Click here to Skip to main content
15,902,492 members
Please Sign up or sign in to vote.
1.00/5 (7 votes)
See more:
I have developed a social portal. I have develop a webusercontrol name UserFriendRequest.ascx and userdetails.aspx is page on which this control appears when user1 send request to user2 frined request is send code works but when user 2 login userfreindrequest control not appears also data is inserted in Friends table.

tablename Friends
Id             int
MyId           int
FriendId       int
Message        text
FriendStatus   bit //this datatype creates the table  allow nulls
FriendShipDate datetime
ImageName      varchar(500)


UserFriendRequest control code is


DataBaseClass dbClass = new DataBaseClass();
   public DataTable dt;
   protected void Page_Load(object sender, EventArgs e)
   {
       if (!Page.IsPostBack)
       {
           GetUserFriendsRequest(int.Parse(Request.QueryString["Id"].ToString()));
       }
   }
   public void GetUserFriendsRequest(int Id)
   {
       string getFriendRequestQuery = "Select * FROM [User] where Id IN (SELECT MyId as Id FROM Friends WHERE FriendId='" + Id + "' AND FriendStatus=0)";//this query does not work when freind request is send FriendStatus column is null and UserFriendRequest control is not display FriendStatus datatype is bit which store null or 1 0r 0  i use logic Friendid=id and Friend status=0  FriendId is updated  but i not understand about FriendStatus the i use the logic when userfriend request control appears When user accepts friendstatus is updated to 1 and when deny friendstatus is 2 i use the right logic?
       dt = dbClass.ConnectDataBaseReturnDT(getFriendRequestQuery);
       if (dt.Rows.Count > 0)
       {
           FreindRequestList.DataSource = dt;
           FreindRequestList.DataBind();
       }
   }
   public string getHREF(object sURL)
   {
       DataRowView dRView = (DataRowView)sURL;
       string Id = dRView["Id"].ToString();
       return ResolveUrl("~/UserDetails.aspx?Id=" + Id);
   }
   public string getSRC(object imgSRC)
   {
       DataRowView dRView = (DataRowView)imgSRC;
       string ImageName = dRView["ImageName"].ToString();
       if (ImageName == "NoImage")
       {
           return ResolveUrl(@"~/UserImage/missing.jpg");
       }
       else
       {
           return ResolveUrl("~/UserImage/" + dRView["ImageName"].ToString());
       }
   }
   protected void FreindRequestList_ItemCommand(object source, DataListCommandEventArgs e)
   {
       if (!object.Equals(Session["UserId"], null))
       {
           if (e.CommandName == "Accept")
           {
               string SenderFriendId = ((HtmlInputHidden)e.Item.FindControl("hiddenId")).Value;
               string MyID = Session["UserId"].ToString();
               string AcceptFriendQuery = "Update Friends set FriendStatus=1 where MyId='" + SenderFriendId + "' AND FriendId='" + MyID + "'";
               dbClass.ConnectDataBaseToInsert(AcceptFriendQuery);
               Response.Redirect("UserDetails.aspx?Id=" + Request.QueryString["Id"].ToString());
           }
           if (e.CommandName == "Deny")
           {
               string SenderFriendId = ((HtmlInputHidden)e.Item.FindControl("hiddenId")).Value;
               string MyID = Session["UserId"].ToString();
               string AcceptFriendQuery = "Update Friends set FriendStatus=0 where MyId='" + SenderFriendId + "' AND FriendId='" + MyID + "'";
               dbClass.ConnectDataBaseToInsert(AcceptFriendQuery);
               Response.Redirect("UserDetails.aspx?Id=" + Request.QueryString["Id"].ToString());
           }
       }
   }

[edit]Code block added, "Ignore HTML..." option disabled - OriginalGriff[/edit]
Posted
Updated 28-Apr-11 5:24am
v3
Comments
OriginalGriff 28-Apr-11 10:43am    
Can't. You didn't ask it.
Joan M 28-Apr-11 10:52am    
This is not a question, please re-read it and correct it.

Thank you.
jim lahey 28-Apr-11 10:57am    
Post a question first then
Manfred Rudolf Bihy 28-Apr-11 11:24am    
Edit: Adjusted title.
Smithers-Jones 28-Apr-11 13:04pm    
om56 is really beyond help.

1 solution

You're missing this:
foreach (Bacon slice in Fridge.getBacon() {
   slice.addSeasoning(new LiquideNitrogen());
}


Now, grow up and write a proper question.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900