How to use one button to insert true into column Status and when clicked the second time will update column Status with false
This is the table clicked the first time
======================================================
UserName | Status
---------------------------------------------------------------
Steve1 | false
----------------------------------------------------------------
This is the table clicked the second time
============================================================
UserName | Status
---------------------------------------------------------------
Steve1 | true
---------------------------------------------------------
protected void btncount_Click(object sender, EventArgs e)
{
if (Session["UserName"] != null && Session["UserName"].ToString() != string.Empty)
{
string username = Session["UserName"].ToString();
Follow(username);
}
else
{
}
public void Follow(string username)
{
string str = ConfigurationManager.ConnectionStrings["CONN"].ConnectionString;
string getADPOST = "Insert INTO USERFollow (UserName,FriendUserName,Status) values (@UserName,@Id,1)";
using (SqlConnection con = new SqlConnection(str))
{
con.Open();
using (SqlCommand cmd = new SqlCommand(getADPOST, con))
{
cmd.Parameters.AddWithValue("@UserName", Session["UserName"].ToString());
cmd.Parameters.AddWithValue("@Id", Request.QueryString["Id"].ToString());
// cmd.Parameters.AddWithValue("@FriendUserName", Request.QueryString["UserName"].ToString());
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable ds = new DataTable();
da.Fill(ds);
}
}
}
}
migold 0 Newbie Poster
AleMonteiro 238 Can I pick my title?
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.