Saafia NM

Saafia NM

  • NA
  • 52
  • 11.1k

Insert a link inside of the Gridview to send a message only

Apr 7 2016 4:01 AM
I have to include a link named 'Mail' inside of the each GridView Rows. While clicking that gridview link i have to send an email message...please help me....
 
 Default.aspx
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False DataSourceID="SqlDataSource2"
onselectedindexchanged="GridView2_SelectedIndexChanged" OnRowCommand="GridView2_RowCommand" OnRowDeleting="GridView2_RowDeleting" >
<RowStyle HorizontalAlign="Center"/>
<Columns>
<asp:CommandField ButtonType ="Link"  ShowDeleteButton ="true"  DeleteText ="Mail" />
</Columns>
<HeaderStyle BackColor="Black" ForeColor="White"></HeaderStyle>
</asp:GridView>
 
Default.aspx.cs
protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName=="Delete")
{
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("[email protected]", "123@"),
EnableSsl = true
};
client.Send("[email protected]", "[email protected]", "test", "Your Auction Price has been fixed for this Product. Inorder to Complete your Purchase kindly pay the Auction Amount");
Response.Write("<script launguage ='java script'> alert('Mail send successfully');</script>");
}
}
protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
}
 
 i tried the above code but i did not get any link inside of my gridview. Help me please....
 

Answers (1)