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 315953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:20:21+00:00 2026-05-12T08:20:21+00:00

My question is fairly simple. This is what I have for the aspx page:

  • 0

My question is fairly simple. This is what I have for the aspx page:

<ul>
    <asp:Repeater runat="server" ID="linksList" OnItemDataBound="linksList_OnItemDataBound" >
    <ItemTemplate>
        <li><asp:HyperLink runat="server" ID="link" /></li>
    </ItemTemplate>
    </asp:Repeater>
</ul>

I’m trying to get a list of hyperlinks from a SQL server into a list. This is what I have in the codebehind:

protected void Page_Load(object sender, EventArgs e)
{
    DataSet ds = Utilities.RunSelectQuery("SELECT *");
    DataTable dt = ds.Tables[0];

    linksList.DataSource = dt;
    linksList.DataBind();
}

How do I change the NavigateUrl and Text properties in the asp:HyperLink after data’s been bound to the Repeater? I want to do this in the codebehind, I can get it to work if I do it using <%# Eval("URL") %> in the aspx page but that’s sort of against what ASP.NET is all about.

Edit: this is the solution that worked for me thanks to womp:

protected void linksList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        DataRowView row = (DataRowView)e.Item.DataItem;
        HyperLink link = (HyperLink)e.Item.FindControl("link");

        link.Text = row["description"].ToString();
        link.NavigateUrl = row["URL"].ToString();
    }
}
  • 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-12T08:20:21+00:00Added an answer on May 12, 2026 at 8:20 am

    Actually, using the Databinder syntax in your templates is a great way to do it, I’m not sure what you mean that it’s “against what ASP.Net is all about”.

    However, if you really want to do it in code, you can do it right in your OnItemDataBound handler (which it looks like you’ve created). Something like this (read: untested) should do the trick:

    void linksList_OnItemDataBound(object Sender, RepeaterItemEventArgs e) 
    {
    
            if (e.Item.ItemType == ListItemType.Item 
                  || e.Item.ItemType == ListItemType.AlternatingItem) {
    
                 DataRow row = e.Item.DataItem as DataRow;
                 Hyperlink link = e.Item.FindControl("link"));
                 link.Text = row["URL"];
                 link.NavigateUrl = row["URL"];
                 }
              }
           }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe this is a fairly simple question but I have no idea where
I have a fairly simple system, and for the purposes of this question there
I have what should be a fairly simple ASP.NET question, and one I thought
This is a fairly simple question (or at least from the outset it should
This is a fairly simple question, but it's one I can't find a firm
This is a fairly simple question. Basically, I'm having a program send HardWare ID's
Hey all. I have a fairly simple question. I am developing a rich iPad
I have a fairly simple database that I inherited. For the purposes of this
I have a fairly simple php/soap header question. Here's what I need. <ns1:Identity token=123456789></ns1:Identity>
All, This would seem like a fairly basic asp.net question - but in all

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.