April 23, 2011

How to create hyperlink in GridView

There are lot of ways to pass values from Gridview.
I am putting one sample method.

<asp:TemplateField HeaderText="Details">
<ItemTemplate>
<asp:HyperLink ID="hlUrlQID" runat="server" NavigateUrl='<%#FormatUrl(Eval("Queue ID"))%>'
Text='<%# Eval("Queue ID")%>'>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>

On code behind page we have to write
protected string FormatUrl(object QID)
{
return "QueueDetails.aspx?QID=" + QID.ToString();
}

No comments:

Post a Comment