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. Using Eval and Bind on UserControl [modified]

Using Eval and Bind on UserControl [modified]

Scheduled Pinned Locked Moved ASP.NET
tutorialsysadminhelpquestion
6 Posts 3 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.
  • B Offline
    B Offline
    badgrs
    wrote on last edited by
    #1

    Hi, I've created a UserControl with some public properties that get exposed via the form tag on the aspx page. However I can't seem to get Eval and Bind to work with any properties on the control. I keep getting a compilation error "Server tag not well formed`". Heres an example: <uc1:MyUserControl ID="MyUserControl1" runat="server" MyPoperty="<%# Eval("ItemProperty") %>" /> Does anyone know how to get this to work on a UserControl? I've tried adding the BindableAttribute(true) directive to the properties but no luck. Cheers, Rory -- modified at 8:14 Monday 23rd April, 2007`

    R R 2 Replies Last reply
    0
    • B badgrs

      Hi, I've created a UserControl with some public properties that get exposed via the form tag on the aspx page. However I can't seem to get Eval and Bind to work with any properties on the control. I keep getting a compilation error "Server tag not well formed`". Heres an example: <uc1:MyUserControl ID="MyUserControl1" runat="server" MyPoperty="<%# Eval("ItemProperty") %>" /> Does anyone know how to get this to work on a UserControl? I've tried adding the BindableAttribute(true) directive to the properties but no luck. Cheers, Rory -- modified at 8:14 Monday 23rd April, 2007`

      R Offline
      R Offline
      Rajesh B Prajapati
      wrote on last edited by
      #2

      User Control Cannot support eval functions. so you can not user this is UserControl

      rajeshprajapati

      1 Reply Last reply
      0
      • B badgrs

        Hi, I've created a UserControl with some public properties that get exposed via the form tag on the aspx page. However I can't seem to get Eval and Bind to work with any properties on the control. I keep getting a compilation error "Server tag not well formed`". Heres an example: <uc1:MyUserControl ID="MyUserControl1" runat="server" MyPoperty="<%# Eval("ItemProperty") %>" /> Does anyone know how to get this to work on a UserControl? I've tried adding the BindableAttribute(true) directive to the properties but no luck. Cheers, Rory -- modified at 8:14 Monday 23rd April, 2007`

        R Offline
        R Offline
        RichardGrimmer
        wrote on last edited by
        #3

        ISn't it DataBinder.Eval() ?

        "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

        B 1 Reply Last reply
        0
        • R RichardGrimmer

          ISn't it DataBinder.Eval() ?

          "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

          B Offline
          B Offline
          badgrs
          wrote on last edited by
          #4

          Yeah I keep seeing examples with that as well but I haven't bothered looking into why. Best guess is that was the .NET 1.1 way of doing it - I'm pretty sure just using Eval() or Bind() now does the same thing - I could be wrong. Either way I tried that as well and it didn't work. It seems the same is also true of certain controls themselves, such as the Image control, you can't use any databinding expressions with that but you can with a Label control. Can someone explain what controls can have expressions and what ones can't? I can't see any obvious difference in the classes.

          R 1 Reply Last reply
          0
          • B badgrs

            Yeah I keep seeing examples with that as well but I haven't bothered looking into why. Best guess is that was the .NET 1.1 way of doing it - I'm pretty sure just using Eval() or Bind() now does the same thing - I could be wrong. Either way I tried that as well and it didn't work. It seems the same is also true of certain controls themselves, such as the Image control, you can't use any databinding expressions with that but you can with a Label control. Can someone explain what controls can have expressions and what ones can't? I can't see any obvious difference in the classes.

            R Offline
            R Offline
            RichardGrimmer
            wrote on last edited by
            #5

            Just found this in our codebase... Try passing the Container.DataItem part and see what happens.... This link "explains" lol... http://msdn2.microsoft.com/en-us/library/4hx47hfe.aspx[^] This code binds to a dataset though, rather than a custom object...are you able to bind to a dataset? "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

            B 1 Reply Last reply
            0
            • R RichardGrimmer

              Just found this in our codebase... Try passing the Container.DataItem part and see what happens.... This link "explains" lol... http://msdn2.microsoft.com/en-us/library/4hx47hfe.aspx[^] This code binds to a dataset though, rather than a custom object...are you able to bind to a dataset? "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

              B Offline
              B Offline
              badgrs
              wrote on last edited by
              #6

              Ah what an idiot! I had double quotes instead of single ones! How many times I've done that before I don't know...

              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