i have just a button and a lable inside formview, so i want to insert following to a table one the user clicks then display it on the lable in the formview
here is what i tried
html
<asp:FormView ID="FormView1follow" runat="server" Width="100%">
<EmptyDataTemplate>
<ul class="nav navbar-nav ">
<li>
<asp:LinkButton ID="LinkButton39" runat="server">
<asp:Label ID="Label22" runat="server" Font-Bold="True" Font-Size="X-Large" Text="Follow"></asp:Label>
</asp:LinkButton>
</li>
</ul>
</EmptyDataTemplate>
<ItemTemplate>
<ul class="nav navbar-nav ">
<li> </li>
<li>
<asp:LinkButton ID="btnNotFriend" runat="server" ToolTip="follow user" Font-Bold="True">
<i class="" style="margin-right: 2px"></i>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("Following") %>' Font-Bold="True"
ForeColor="#006699" />
</asp:LinkButton></li></ul>
</ItemTemplate>
</asp:FormView>
Code
protected void FormView1follow_ItemCommand(object source, FormViewCommandEventArgs e)
{
try
{
if (this.Page.User.Identity.IsAuthenticated)
{
string username = this.Page.User.Identity.Name;
string id = e.CommandArgument.ToString();
// string username6;
if (e.CommandName == "Insertstatus")
{
//int userPostId = e.CommandArgument;
// TextBox txtComments = (TextBox)e.Item.FindControl("txtComments");
// TextBox txtaddress = (TextBox)e.Item.FindControl("txtsaddress");
// TextBox txtrollno = (TextBox)e.Item.FindControl("txtsrollno");
SqlCommand cmd = new SqlCommand("InsertFollow", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", Request.QueryString["Id"].ToString());
cmd.Parameters.AddWithValue("@FriendUserName", Request.QueryString["Id"].ToString());
cmd.Parameters.AddWithValue("@FollowStatus", 1);
cmd.Parameters.AddWithValue("@Count", 1);
// cmd.Parameters.AddWithValue("@Id", id);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
cmd.Dispose();
//Response.Write("<script type=\"text/javascript\">alert('Comment Posted Successfully!!!');</script>");
// BindDatalist(username);
}
}
}
catch (Exception ex)
{
throw ex;
}
}