Using Eval and Bind on UserControl [modified]
-
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
andBind
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`
-
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
andBind
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`
User Control Cannot support eval functions. so you can not user this is UserControl
rajeshprajapati
-
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
andBind
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`
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
-
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
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.
-
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.
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
-
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