iFocus.Life News News - Breaking News & Top Stories - Latest World, US & Local News,Get the latest news, exclusives, sport, celebrities, showbiz, politics, business and lifestyle from The iFocus.Life,

How to Insert a MailTo Hyperlink in GridView

104 14
    • 1). Open the Visual Studio software and open the Web project for your online application. Double-click the source code file you want to use to edit the GridView content.

    • 2). Create a DataTable control and add a row for the HyperlinkField. The DataTable contains the data for the GridView, and you later bind the DataTable to the GridView to display the data. The following code creates the DataTable and creates the row:

      DataTable dt = new DataTable();
      DataRow dr = null;
      dr = dt.NewRow();

    • 3). Create the HyperlinkField control. The following code creates the HyperlinkField and add the link to the control:

      HyperLinkField link = new HyperLinkField();
      link.NavigateUrl = "mysite.com";

      Replace "mysite.com" with the URL for the hyperlink.

    • 4). Add the HyperlinkField to the DataRow object. The following code adds the hyperlink and add the row to the table:

      dr["link"] = link;

    • 5). Bind the DataTable to the GridView, which displays the link to the user. The following code binds the table:

      Gridview1.DataSource = dt;
      Gridview1.DataBind();

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time
You might also like on "Technology"

Leave A Reply

Your email address will not be published.