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#.
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..
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.
Use a Asp.Net HyperLink control. You can create the url passed to the Hyperlink control by using String.Format().
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.