late-bound-evaluation

Trying to embed a DataItem within an asp:Image control's ImageUrl property

梦想与她 提交于 2019-12-12 05:07:33
问题 I have the following Image control within a repeater. I'm trying to get the username to render in between ~/profilepics/ and .jpg but I get the following rendered output /profilepics/%3C%25#DataBinder.Eval(Container.DataItem,%20%22usernameFrom%22)%20%25%3E.jpg Here is the markup <asp:Image ID="Image1" runat="server" ImageUrl='~/profilepics/<%#DataBinder.Eval(Container.DataItem, "username") %>.jpg' /> I have also tried the same but with double quotes and get the same result. <asp:Image ID=

How to call extension methods using Eval in a databound control

*爱你&永不变心* 提交于 2019-12-04 18:29:46
问题 I have a simple extension method on the int type so I can do the following: string timeLength = 61.ToTime() // timeLength will be "1:01" This works great in code, but I want to use this extension method in a Repeater Template. When databinding I want to do the following: <%# Eval("LengthInSeconds").ToTime() %> That didn't work so I tried: <%# ((int) Eval("LengthInSeconds")).ToTime() %> and it still didn't work. The JIT compiler is not seeing my extension method and I do have the proper import

How to call extension methods using Eval in a databound control

混江龙づ霸主 提交于 2019-12-03 11:08:44
I have a simple extension method on the int type so I can do the following: string timeLength = 61.ToTime() // timeLength will be "1:01" This works great in code, but I want to use this extension method in a Repeater Template. When databinding I want to do the following: <%# Eval("LengthInSeconds").ToTime() %> That didn't work so I tried: <%# ((int) Eval("LengthInSeconds")).ToTime() %> and it still didn't work. The JIT compiler is not seeing my extension method and I do have the proper import statement in the page. My only idea for solving this is to replace the Eval with a Literal control and