<asp:ImageButton ID="lnklike" runat="server" ImageUrl="~/Images/thumbsup.png" height="20px" Width="20px" CommandName="like" CommandArgument='<%# Eval("ScrapId")%>'/> <asp:UpdatePanel runat="server" id="UpdatePanel" updatemode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger controlid="lnklike" eventname="Click" /> </Triggers> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Controls_GetUserScraps.abc((int)Eval("ScrapId")) %>' /> </ContentTemplate> </asp:UpdatePanel>
protected void GridViewRowCommand(Object sender, GridViewCommandEventArgs e) { var scrapId = Int32.Parse(e.CommandArgument.ToString()); switch (e.CommandName) { case "like": GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer); int index = row.RowIndex; string chklike = "select likestatus from tbl_like where fromid='" + Session["UserId"] + "' and scrapid='" + scrapId + "'"; int a = dbo.GetLikesMethod(chklike); string chkthumbsdown = "select thumbsdownstatus from tbl_like where fromid='" + Session["UserId"] + "' and scrapid='" + scrapId + "'"; int b = dbo.GetLikesMethod(chkthumbsdown); if (a == 0 && b == 0) { string sendlike = "insert into tbl_like (ScrapId,FromId,LikeStatus) values('" + scrapId + "','" + Session["UserId"] + "',1)"; dbo.insert(sendlike); Label lbl=(Label)GridViewUserScraps.Rows[index].FindControl("Label1"); lbl.Text = "20"; //GetUserScraps(int.Parse(Request.QueryString["Id"].ToString())); }
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MaintainScrollPositionOnPostback="true" %>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)