Hi sambath,
Check this example. Now please take its reference and correct your code.
Suppose you want to share 2nd GridView row then instead of using HyperLink use LinkButton and OnClick event of LinkButton set the other GridView Row visibility to false and create a Function in JavaScript that will share the url in whats app and call the JavaScript function on LinkButton click event.
HTML
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Country" HeaderText="Country" />
</Columns>
</asp:GridView>
<br />
<asp:LinkButton ID="lnkShare" class="whatsapp w3_whatsapp_btn w3_whatsapp_btn_large"
OnClick="Click" runat="server">Share</asp:LinkButton>
<script type="text/javascript">
function ShareOnWhatsApp() {
window.open('whatsapp://send?text=%20Take%20a%20look%20at%20this%20awesome%20page%20-%20' + encodeURIComponent(document.URL));
return false;
}
</script>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Country",typeof(string)) });
dt.Rows.Add(1, "John Hammond", "United States");
dt.Rows.Add(2, "Mudassar Khan", "India");
dt.Rows.Add(3, "Suzanne Mathews", "France");
dt.Rows.Add(4, "Robert Schidner", "Russia");
this.gvCustomers.DataSource = dt;
this.gvCustomers.DataBind();
}
}
protected void Click(object sender, EventArgs e)
{
// Share only 2nd row.
foreach (GridViewRow row in this.gvCustomers.Rows)
{
if (row.RowIndex != 2)
{
row.Visible = false;
}
}
string script = "window.onload = function() { ShareOnWhatsApp(); };";
ClientScript.RegisterStartupScript(this.GetType(), "script", script, true);
}