locked
Send Gridview Data To Whats app number RRS feed

  • Question

  • User-807418713 posted
    Hello
    I have one gridview on button click it should sent the gridview to what's app no.. 91**********

    How to do this
    Friday, June 5, 2020 4:07 AM

All replies

  • User288213138 posted

    Hi Gopi.MCA,

    I have one gridview on button click it should sent the gridview to what's app no.. 91**********

    Can you tell me what is app..91?

    Best regards,

    Sam

    Friday, June 5, 2020 5:52 AM
  • User-807418713 posted
    Hello

    As Everyone We Know There Is What'sApp Massaging Android Software Most Commonly Using Application.

    If I click send button gridview data should show on given what'sApp number.

    Thanking You
    Friday, June 5, 2020 6:30 AM
  • User288213138 posted

    Hi Gopi.MCA,

    As Everyone We Know There Is What'sApp Massaging Android Software Most Commonly Using Application.

    If I click send button gridview data should show on given what'sApp number.

    You can try below code, On click of share button the selected row will be generated in the url as whatsapp://send/?text=Reg No.: 1,Name: John Hammond,Country: United States.

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnSelectedIndexChanged="OnSelectedIndexChanged">
        <Columns>
            <asp:BoundField DataField="Id" HeaderText="Id" />
            <asp:BoundField DataField="Name" HeaderText="Name" />
            <asp:BoundField DataField="Country" HeaderText="Country" />
            <asp:ButtonField Text="Select" CommandName="Select" />
        </Columns>
    </asp:GridView>
    <asp:LinkButton ID="lnkShare" Text="Share" runat="server" OnClick="lnkShare_Click" />
    <script type="text/javascript">
        function ShareOnWhatsApp(id, name, country) {
            window.open('whatsapp://send?text=Reg No.: ' + id + ',Name: ' + name + ',Country: ' + country + '');
            return false;
        }
    </script>
    
    protected int selectedIndex = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.AddRange(new System.Data.DataColumn[3] {
                    new System.Data.DataColumn("Id", typeof(int)),
                    new System.Data.DataColumn("Name", typeof(string)),
                    new System.Data.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");
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
    }
     
    protected void OnSelectedIndexChanged(object sender, EventArgs e)
    {
        selectedIndex = GridView1.SelectedIndex;
    }
     
    protected void lnkShare_Click(object sender, EventArgs e)
    {
        GridViewRow row = this.GridView1.Rows[selectedIndex];
        string id = row.Cells[0].Text;
        string name = row.Cells[1].Text;
        string country = row.Cells[2].Text;
        string script = "window.onload = function() { ShareOnWhatsApp('" + id + "','" + name + "','" + country + "'); };";
        ClientScript.RegisterStartupScript(this.GetType(), "script", script, true);
    }

    More information about send GridView data in WhatsApp in ASP.Net you can refer to this link:

    https://www.aspforums.net/Threads/186621/Send-GridView-row-details-in-WhatsApp-in-ASPNet/

    Best regards,

    Sam

    Friday, June 5, 2020 7:27 AM