1

In my application I have DataSet containing name and Id of user and I want to create a dynamic hyperlink of the all the user name. Please anyone tell me how to create dynamic hyperlink using C#.

5 Answers 5

2

As @Ashley John said,

        HyperLink DynLink = new HyperLink();
        DynLink.ID = "DynLink";
        DynLink.Text = "This Link Is been Created Dynamically from code behind";
        DynLink.NavigateUrl = "~/TestPage.aspx";

        PlaceHolder1.Controls.Add(DynLink);

I have used a placeholder as a container to hold the dynamically generated Hyperlink..

Sign up to request clarification or add additional context in comments.

Comments

1
  1. Create a new instance of Hyperlink Control
  2. Set its URL property.
  3. Add the Control to the placeholder(or Gridview controls collection if you are using it inside a Gridview) where you want it to get displayed.

Comments

0

Use a Asp.Net HyperLink control. You can create the url passed to the Hyperlink control by using String.Format().

Comments

0

If you want to create a list of all hyperlinks you could have a look at the Repeater and use Eval("...") in the template to render out the link. That way, you can define more in markup then in code.

Comments

0

We can create Dynamic Hyperlink using following Syntax:

<asp:DynamicHyperlink
    ID="string"
    Action="Details|Edit|Insert|List"
    ContextTypeName="string"
    DataField="string"
    TableName="string"
    OnDataBinding="DataBinding event handler"
    OnPreRender="PreRender event handler"/>

For more detail just go to this link. You will get a Demo Project Showing use of Dynamic Hyperlink and Linq.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.