Micah David

Micah David

  • NA
  • 25
  • 9k

How to check if a user in connected to another user on login

Aug 10 2016 12:30 PM
I have two lables but on must appear as a default when a user logs in<br />the two labels are Lable A, amd Lable B<br /><br />Now i have two tables called User Account table and User Connected table<br /><br />Example<br /><br />User Connected table<br />-------------------------------------------------------------------------------------------------------<br />ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UserName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FriendUserName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Status &nbsp;<br />--------------------------------------------------------------------------------------------------------<br />1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Mary22&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stonek33&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; true<br />-------------------------------------------------------------------------------------------------------<br />-----------------------------------------------------------------&nbsp; -----------------------------------<br />2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; brown22&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stonek33&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;true<br />-------------------------------------------------------------------------------------------------------<br /><br /><br />User Account table <br />--------------------------------------------------------------------------------<br />ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UserName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />-----------------------------------------------------------------------------------<br />1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Mary22&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />-------------------------------------------------------------------------------------<br />----------------------------------------------------------------------------------<br />2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; brown22&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />-------------------------------------------------------------------------------------<br />----------------------------------------------------------------------------------<br />3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stonek33&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />-------------------------------------------------------------------------------------<br />----------------------------------------------------------------------------------<br />4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; liter22&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />-------------------------------------------------------------------------------------<br /><br />So now lets take for example that mary22, Mary22 is connected to Stonek33 and the status of their connection us true, so if mary logs in she wants to see those she is connect to, so when she clicks on names of any <br />of the users displayed on her page she will be redirected to the users page and she will see the lable showing yes connected.<br />But you can see from the table that mary22 is not connected to brown22 and so if mary or brown22 visits each others page they will see not connected lable.<br /><br />i ony created a html of it&nbsp; but i need help on the code behind<br /><br /><div>HTML </div><div>&nbsp;</div><div><div class="dp-highlighter"><ol class="dp-xml" start="1"><li class="alt"><span><span class="tag">&lt;</span><span class="tag-name">asp:FormView</span><span>&nbsp;</span><span class="attribute">ID</span><span>=</span><span class="attribute-value">"FormView1follow"</span><span>&nbsp;</span><span class="attribute">runat</span><span>=</span><span class="attribute-value">"server"</span><span>&nbsp;</span><span class="attribute">OnDataBound</span><span>=</span><span class="attribute-value">"OnDataBound"</span><span>&nbsp;</span><span class="attribute">Width</span><span>=</span><span class="attribute-value">"100%"</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="attribute">AllowPaging</span><span>=</span><span class="attribute-value">"true"</span><span>&nbsp;</span><span class="attribute">OnPageIndexChanging</span><span>=</span><span class="attribute-value">"OnPageIndexChanging"</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">ItemTemplate</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">asp:HiddenField</span><span>&nbsp;</span><span class="attribute">ID</span><span>=</span><span class="attribute-value">"hfUserName"</span><span>&nbsp;</span><span class="attribute">runat</span><span>=</span><span class="attribute-value">"server"</span><span>&nbsp;</span><span class="attribute">Value</span><span>=</span><span class="attribute-value">'&lt;%#&nbsp;Eval("UserName")&nbsp;%&gt;'</span><span>&nbsp;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">asp:HiddenField</span><span>&nbsp;</span><span class="attribute">ID</span><span>=</span><span class="attribute-value">"hfFriendsUserName"</span><span>&nbsp;</span><span class="attribute">runat</span><span>=</span><span class="attribute-value">"server"</span><span>&nbsp;</span><span class="attribute">Value</span><span>=</span><span class="attribute-value">'&lt;%#&nbsp;Eval("FriendUserName")&nbsp;%&gt;'</span><span>&nbsp;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">asp:HiddenField</span><span>&nbsp;</span><span class="attribute">ID</span><span>=</span><span class="attribute-value">"hfStatus"</span><span>&nbsp;</span><span class="attribute">runat</span><span>=</span><span class="attribute-value">"server"</span><span>&nbsp;</span><span class="attribute">Value</span><span>=</span><span class="attribute-value">'&lt;%#&nbsp;Eval("Status")&nbsp;%&gt;'</span><span>&nbsp;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">asp:LinkButton</span><span>&nbsp;</span><span class="attribute">ID</span><span>=</span><span class="attribute-value">"btnFriend"</span><span>&nbsp;</span><span class="attribute">runat</span><span>=</span><span class="attribute-value">"server"</span><span>&nbsp;</span><span class="attribute">ToolTip</span><span>=</span><span class="attribute-value">"follow&nbsp;user"</span><span>&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="attribute">Font-Bold</span><span>=</span><span class="attribute-value">"True"</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">i</span><span>&nbsp;</span><span class="attribute">class</span><span>=</span><span class="attribute-value">""</span><span>&nbsp;</span><span class="attribute">style</span><span>=</span><span class="attribute-value">"margin-right:&nbsp;2px"</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">i</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">asp:Label</span><span>&nbsp;</span><span class="attribute">ID</span><span>=</span><span class="attribute-value">"lblFriend"</span><span>&nbsp;</span><span class="attribute">runat</span><span>=</span><span class="attribute-value">"server"</span><span>&nbsp;</span><span class="attribute">Text</span><span>=</span><span class="attribute-value">'&lt;%#&nbsp;Eval("Status")&nbsp;%&gt;'</span><span>&nbsp;</span><span class="attribute">CssClass</span><span>=</span><span class="attribute-value">"&nbsp;btn&nbsp;btn-twitter&nbsp;fa&nbsp;fa-user"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;/</span><span class="tag-name">asp:LinkButton</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span><span class="tag">&lt;</span><span class="tag-name">asp:LinkButton</span><span>&nbsp;</span><span class="attribute">ID</span><span>=</span><span class="attribute-value">"btnNotFriend"</span><span>&nbsp;</span><span class="attribute">runat</span><span>=</span><span class="attribute-value">"server"</span><span>&nbsp;</span><span class="attribute">ToolTip</span><span>=</span><span class="attribute-value">"follow&nbsp;user"</span><span>&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="attribute">Font-Bold</span><span>=</span><span class="attribute-value">"True"</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">i</span><span>&nbsp;</span><span class="attribute">class</span><span>=</span><span class="attribute-value">""</span><span>&nbsp;</span><span class="attribute">style</span><span>=</span><span class="attribute-value">"margin-right:&nbsp;2px"</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">i</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">asp:Label</span><span>&nbsp;</span><span class="attribute">ID</span><span>=</span><span class="attribute-value">"lblUnFriend"</span><span>&nbsp;</span><span class="attribute">runat</span><span>=</span><span class="attribute-value">"server"</span><span>&nbsp;</span><span class="attribute">Text</span><span>=</span><span class="attribute-value">'&lt;%#&nbsp;Eval("Status")&nbsp;%&gt;'</span><span>&nbsp;</span><span class="attribute">CssClass</span><span>=</span><span class="attribute-value">"&nbsp;&nbsp;btn&nbsp;btn-twitter&nbsp;fa&nbsp;fa-user-plus"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;/</span><span class="tag-name">asp:LinkButton</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;/</span><span class="tag-name">ItemTemplate</span><span class="tag">&gt;</span><span>&nbsp; <br /></span></span></li></ol></div>&nbsp;</div>

Answers (1)