Hi micah,
I have created sample. You need to change as per your requirement.
HTML
<div>
<asp:Label ID="lblMerged" Text="Merged" runat="server" Visible="false" />
<asp:Label ID="lblNotMerged" Text="NotMerged" runat="server" Visible="false" />
<asp:Label ID="lblUserNotValid" Text="User Not Valid" runat="server" Visible="false" />
</div>
Code
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["UserName"] != null)
{
if (!IsPostBack)
{
DataTable dt = GetData(Request.QueryString["UserName"]);
if (dt.Rows.Count > 0)
{
string FriendUserName = string.Empty;
string userName = dt.Rows[0]["UserName"].ToString().ToLower();
if (userName != "user not valid")
{
FriendUserName = dt.Rows[0]["FriendUserName"].ToString().ToLower();
if (userName != FriendUserName)
{
lblMerged.Visible = true;
}
else
{
lblNotMerged.Visible = true;
}
}
else
{
lblUserNotValid.Visible = true;
}
}
}
}
}
private DataTable GetData(string userName)
{
DataTable dt = new DataTable();
string constr = ConfigurationManager.ConnectionStrings[1].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", userName);
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
sda.Fill(dt);
}
con.Close();
}
}
return dt;
}
SQL
CREATE PROC Getbuttons
@UserName VARCHAR(50)
AS
BEGIN
IF EXISTS(SELECT UserName FROM User3 WHERE UserName = @UserName)
BEGIN
SELECT UserName,FriendUserName FROM UserFollow WHERE UserName = @UserName OR FriendUserName = @UserName
END
ELSE
BEGIN
SELECT 'User not valid' AS UserName
END
END
--EXEC Getbuttons 'Steve1'