title: Change an ASP.NET control's properties in a Repeater control
body: <p>My question is fairly simple. This is what I have for the aspx page:</p>
  
  <pre><code>&lt;ul&gt;
      &lt;asp:Repeater runat="server" ID="linksList" OnItemDataBound="linksList_OnItemDataBound" &gt;
      &lt;ItemTemplate&gt;
          &lt;li&gt;&lt;asp:HyperLink runat="server" ID="link" /&gt;&lt;/li&gt;
      &lt;/ItemTemplate&gt;
      &lt;/asp:Repeater&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I'm trying to get a list of hyperlinks from a SQL server into a list. This is what I have in the codebehind:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      DataSet ds = Utilities.RunSelectQuery("SELECT *");
      DataTable dt = ds.Tables[0];
  
      linksList.DataSource = dt;
      linksList.DataBind();
  }
  </code></pre>
  
  <p>How do I change the <code>NavigateUrl</code> and <code>Text</code> properties in the <code>asp:HyperLink</code> after data's been bound to the <code>Repeater</code>? I want to do this in the codebehind, I can get it to work if I do it using <code>&lt;%# Eval("URL") %&gt;</code> in the aspx page but that's sort of against what ASP.NET is all about.</p>
  
  <p>Edit: this is the solution that worked for me thanks to womp:</p>
  
  <pre><code>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();
      }
  }
  </code></pre>