ASP.net中继器中的Eval在另一个控件中不起作用 [英] Eval inside an ASP.net repeater doesn't work inside another control

查看:65
本文介绍了ASP.net中继器中的Eval在另一个控件中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Reapter控件,其中有一个自定义服务器端控件.当我放置代码时:

I have a Reapter control with a custom server side control inside of it. When I place the code:

<%# Eval("DateAdded") %>

在转发器的项目模板内,它可以正常工作,但是当我将其放置在转发器内的自定义服务器控件中时,它不起作用.是否可以执行Parent.Eval()或Container.Eval()之类的操作以返回到Reapeter的上下文,而不是自定义控件?

inside the item template of the repeater it works fine, but when I place it inside the custom server control inside the repeater, it doesn't work. Is it possible to do something like Parent.Eval() or Container.Eval() to get back to the context of the Reapeter rather than the custom control?

推荐答案

转发器是数据绑定的,放置此eval语句的控件不是.您需要使用属性将值传递给控件.

The repeater is databound, the control that you are placing this eval statement in isn't. You'll need to pass the value to the control using a property.

例如:

<uc1:MyControl MyProperty='<%# Eval("DateAdded") %>' />

您现在可以访问控件内的 MyProperty 属性以访问此值.

You can now access the MyProperty property inside your control to access this value.

这篇关于ASP.net中继器中的Eval在另一个控件中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆