hello
what is wrong with my code
protected void Button48_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[1] {
new DataColumn("mobile")});
string mobile = (FindControl("mobiletxt") as Label).Text.Trim();
dt.Rows.Add(mobile);
string url = string.Format("https://api.whatsapp.com/send?phone=00965{0}&text=&source=&data=&app_absent=/Insert", "mobiletxt");
System.Diagnostics.Process.Start(url);
}
ASP.net Griddview copy text mobile number
<asp:TemplateField HeaderText="mobile">
<ItemTemplate>
<asp:Label ID="mobiletxt" Text='<%# Eval("mobile") %>' runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button48_Click" Text="WhatsApp" BackColor="#00CC00" Font-Bold="True" ForeColor="White" />
</ItemTemplate>
<ItemStyle Width="150px" HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
Error
Server Error in '/' Application.
An object reference is not set for an object's methylation.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: An object reference is not set to an instance of an object.
Source Error:
Line 681: new DataColumn("mobile")});
Line 682:
Line 683: string mobile = (FindControl("mobiletxt") as Label).Text.Trim();
Line 684: dt.Rows.Add(mobile);
Line 685: string url = string.Format("https://api.whatsapp.com/send?phone=965{0}&text=&source=&data=&app_absent=/Insert", "mobiletxt");
|