Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6087587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:53:14+00:00 2026-05-23T11:53:14+00:00

I have a HyperLinkField which I populate with the urls from a datatable, the

  • 0

I have a HyperLinkField which I populate with the urls from a datatable, the field in the datatable is called EncodedAbsUrl.

However, I want to connect this link to a code behind method instead

What I do now

var encodedAbsUrl = new string[] { "EncodedAbsUrl" };
var hf = new HyperLinkField
{
    HeaderText = "Link",
    DataTextField = "ServerUrl",
    DataNavigateUrlFields = encodedAbsUrl,
    DataNavigateUrlFormatString = "{0}",
    Target = "_blank",
};

But id like to do something like this

var encodedAbsUrl = new string[] { "EncodedAbsUrl" };
var hf = new HyperLinkField
{
    HeaderText = "Link",
    DataTextField = "ServerUrl",
    NavigateUrl = clicker(encodedAbsUrl["{0}"]),
    Target = "_blank",
};


protected void clicker(string url)
{
    //...
}

Well you can see my attempts are unsuccessful 🙂

Any advice is appreciated

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:53:14+00:00Added an answer on May 23, 2026 at 11:53 am

    if you will use HyperLinkField so you will not need to Clicker or any postback event because this field will be rendered as <a> tag. I made a sample example using HyperLink control and LinkButton control that will be postback your page.

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            gv.DataSource = [YourDataSource];
            gv.DataBind();
        }
    }
    protected void Clicker(Object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Link")
        {
            Response.Redirect(e.CommandArgument.ToString());
        }
    }
    protected void gv_DataBinding(Object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HyperLink hlink = e.Row.FindControl("hlink") as HyperLink;
            hlink.NavigateUrl = ((Person)e.Row.DataItem).NavUrl;
            hlink.Text = ((Person)e.Row.DataItem).NavUrl;
            hlink.Target = "_blank";
    
            LinkButton lnkButton = e.Row.FindControl("lnkButton") as LinkButton;
            lnkButton.Text = ((Person)e.Row.DataItem).NavUrl;
            lnkButton.CommandName = "Link";
            lnkButton.CommandArgument = ((Person)e.Row.DataItem).NavUrl;
        }
    }
    

    you GridView will like this

    <asp:GridView runat="server" ID="gv" OnRowCommand="Clicker" OnRowDataBound="gv_DataBinding"
        AutoGenerateColumns="false">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:HyperLink runat="server" ID="hlink"></asp:HyperLink>
                    <asp:LinkButton runat="server" ID="lnkButton"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want people to click on a link (generated from an asp:HyperlinkField) and have
I have a custom content type with a custom field of type TEXT. This
Have converted devise new session from erb to Haml but doens't work, this is
Have a photography site that I want to prevent image copying from. How can
I have binded a custom datatable to gridview. Now I want to validate if
I have a asp:GridView with a HyperLinkField . It's DataNavigateUrlFormatString property is set to
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you managed to get Aptana Studio debugging to work? I tried following this,
**Have it working now. I forgot to populate the Array List. How embarrassing. I'm
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.