How to check if a user in user account table is opposite FriendUserName column or UserName Column in USERFollow table and if yes show lable Marged , but if not show lable Not Merged
HTML
<div>
<asp:Label ID="lblMerged" Text="Merged" runat="server" Visible="false" />
<asp:Label ID="lblNotMerged" Text="NotMerged" runat="server" Visible="false" />
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserName"] != null && Session["UserName"].ToString() != string.Empty)
{
Session["Name"] = Session["Name"].ToString();
string username = Session["UserName"].ToString();
if (Request.QueryString["UserName"] != null)
{
if (!IsPostBack)
{
DataTable dt = GetData(Request.QueryString["UserName"]);
if (dt.Rows.Count > 0)
{
string userStatus = dt.Rows[0]["UserStatus"].ToString().ToLower();
if (userStatus == "exist")
{
lblMerged.Visible = true;
}
else if (userStatus == "notexist")
{
lblNotMerged.Visible = true;
}
}
}
}
}
}
private DataTable GetData(string userName)
{
DataTable dt = new DataTable();
string constr = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
string query = "Getbuttons";
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand(query, con))
{
con.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", Request.QueryString["Id"].ToString());
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
sda.Fill(dt);
}
con.Close();
}
}
return dt;
}