动态添加控件ASP.NET直放站 [英] Dynamically adding controls in ASP.NET Repeater

查看:103
本文介绍了动态添加控件ASP.NET直放站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到一种具有正被数据绑定到XML文档的中继器控制我自己。我的客户端现在请求该文本框的哪个正在中继器可以是一个文本框或复选框

我似乎无法找到一个易程基本上做到以下几点:

  IF((System.Xml.XmlNode)e.Item.DataItem.Attributes [型] ==文本)
< ASP:文本框=服务器ID =txtField文本='<%#((System.Xml.XmlNode)的Container.DataItem).InnerText%GT;'的CssClass =性病>< / ASP:文本框>
其他
< ASP:复选框=服务器ID =txtField文本='<%#((System.Xml.XmlNode)的Container.DataItem).InnerText%GT;'的CssClass =性病>< / ASP:文本框>

有没有一个很好的办法,我可以延长我目前没有implementaion必须重写逻辑。如果我可以通过OnItemDataBound注入的控制也将被罚款。但我似乎无法使其工作


解决方案

有关各个文本框和CheckBox控件类似这样的东西在你的标记是什么?


 可见=<%=的eval(型)的ToString()==文本)%>


I find my self having a repeater control which is being databound to an xml document. My client is now requesting that the Textbox's which are being repeater can be either a Textbox or a Checkbox.

I cannot seem to find an easyway to essentially do the following:

if ((System.Xml.XmlNode)e.Item.DataItem.Attributes["type"] == "text")
<asp:TextBox runat="server" ID="txtField" Text='<%#((System.Xml.XmlNode)Container.DataItem).InnerText %>' CssClass="std"></asp:TextBox>
else
<asp:CheckBox runat="server" ID="txtField" Text='<%#((System.Xml.XmlNode)Container.DataItem).InnerText %>' CssClass="std"></asp:TextBox>

Is there a nice way I can extend my current implementaion without have to rewrite the logic. If I could inject the control via "OnItemDataBound" that would also be fine. But I cannot seem to make it work

解决方案

What about something similar to this in your markup in each the textbox and checkbox controls?

Visible=<%= Eval("type").tostring() == "text") %>

这篇关于动态添加控件ASP.NET直放站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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