Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. where i am wrong

where i am wrong

Scheduled Pinned Locked Moved ASP.NET
databasehtmlsysadmindockerhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    astcws
    wrote on last edited by
    #1

    I have a hyperlink control code that need to bind from a database. However, I am still not very familiar with this. Can somebody help me? And may you tell me the rules about bind data to html code? The italic part is the wrong code.... <asp:HyperLink NavigateUrl='index?titlename='<%# container.dataitem("title") %> Runat ="server" ><%# container.dataitem("title") %></asp:HyperLink>

    M 1 Reply Last reply
    0
    • A astcws

      I have a hyperlink control code that need to bind from a database. However, I am still not very familiar with this. Can somebody help me? And may you tell me the rules about bind data to html code? The italic part is the wrong code.... <asp:HyperLink NavigateUrl='index?titlename='<%# container.dataitem("title") %> Runat ="server" ><%# container.dataitem("title") %></asp:HyperLink>

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Hi there. Do a Google search for "DataBinding Syntax". There are lots of articles on this topic. I can see two possible problems with the code - the single quote delimiters should include the databinding too, and you may need to either cast the Container.DataItem object or use DataBinder.Eval. If your datasource is a DataTable for example, you can cast the object as a DataRowView. C#

      NavigateUrl='index?titlename=<%#((DataRowView)Container.DataItem)["title"] %>'

      In VB:

      NavigateUrl='index?titlename=<%# CType(Container.DataItem, DataRowView)("title") %>'

      DataBinder.Eval syntax would look like this:

      NavigateUrl='index?titlename=<%# DataBinder.Eval(Container.DataItem, "title") %>'

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups