I have three columns in table, column 1, column 2 and column status. On page I have two buttons, button A and button B. What I want to achieve is, if the status of column 1 and column 2 is false show button A and hide button B , But if the status of column 1 and column 2 is true hide button A and show button B.
In column 1 you have john and column 2 you have Mary and then column status can be false or true.
Please any idea on how to make it work?
Loading
Micah DavidPosted Aug 8, 2016, 8:07 AM
Micah DavidPosted Mar 5, 2016, 11:21 AM
{
{
if (!string.IsNullOrEmpty(Session["UserName"].ToString()))
{
string username = Session["UserName"].ToString();
Getfollower(username);
}
}
}
public void Getfollower(string username)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CONNECTION"].ConnectionString);
SqlCommand cmd = new SqlCommand("SELECT * FROM USERFollow WHERE FriendUserName =@FriendUserName", con);
cmd.Parameters.AddWithValue("@FriendUserName", Session["UserName"].ToString());
cmd.Parameters.AddWithValue("@Id", Request.QueryString["Id"].ToString());
// cmd.Parameters.AddWithValue("@UserName", username1);
// cmd.Parameters.AddWithValue("@FriendUserName", username1);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
string userName = username.Trim();
string followStatus = string.Empty;
string friendUserName = username.Trim();
// string userName = username1.Trim();
// string friendUserName2 = string.Empty;
// string followStatus2 = string.Empty;
while (dr.Read())
{
userName = dr["UserName"].ToString().Trim();
followStatus = dr["FollowStatus"].ToString().Trim();
friendUserName = dr["FriendUserName"].ToString().Trim();
}
if ((userName.ToLower() != friendUserName) && (followStatus.ToLower() == "true"))
{
btnUnFollow.Visible = true;
btnFollow.Visible = false;
}
else
{
btnUnFollow.Visible = false;
btnFollow.Visible = true;
}
// while (dr.Read())
{
//userName = dr["UserName"].ToString().Trim();
//followStatus = dr["FollowStatus"].ToString().Trim();
//friendUserName = dr["UserName"].ToString().Trim();
if ((userName.ToLower() != friendUserName) && (followStatus.ToLower() == "false"))
{
btnUnFollow.Visible = false;
btnFollow.Visible = true;
}
else
{
btnUnFollow.Visible = true;
btnFollow.Visible = false;
}
con.Close();
{
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[USERFollow](
[Id] [int] IDENTITY(1,1) NOT NULL,
[UserName] [nvarchar](500) NULL,
[FriendUserName] [nvarchar](500) NULL,
[FollowStatus] [bit] NULL,
[BlockUserStatus] [bit] NULL,
[SendDate] [datetime] NULL,
CONSTRAINT [PK_USERFollow] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[USERFollow] ADD CONSTRAINT [DF_USERFollow_CommunityStatus] DEFAULT ((0)) FOR [FollowStatus]
GO
ALTER TABLE [dbo].[USERFollow] ADD CONSTRAINT [DF_USERFollow_Status] DEFAULT ('false') FOR [BlockUserStatus]
GO
ALTER TABLE [dbo].[USERFollow] ADD CONSTRAINT [DF_USERFollow_SendDate] DEFAULT (getdate()) FOR [SendDate]
GO
-------------------------------------------------------------
Dorababu MekaPosted Mar 1, 2016, 1:36 AM