简体   繁体   English

如何访问ItemTemplate中的数据列表htmlanchor(href)控件?

[英]how have access to datalist htmlanchor(href) control inside ItemTemplate?

here the datalist with linkresponder like htmlanchor control 这里的数据列表与htmlanchor控件一样具有linkresponder

 <asp:DataList ID="DataListComment" runat="server" DataKeyField="username" 
            EnableViewState="False" RepeatColumns="1">

        <ItemTemplate>

        <br />


    <a href='<%# Eval("commentid", "comment.aspx?commentid={0}") %>'
 runat="server" id="linkresponder" text='<%# Eval("commentname") %>'>



   <asp:Label ID="Label2" runat="server" 
                Text='<%# Eval("commentdate") %>' />


</a>


   </ItemTemplate>



    </asp:DataList>

my try with no result 我的尝试没有结果

 foreach
                         (DataListItem item in DataListComment.Items)
                            {

                                HtmlAnchor link = item.FindControl("linkresponder") as HtmlAnchor;

                                link.Visible = false;



                            }

将锚标记转换为asp:LinkButtonasp:HyperLink控件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何找到位于datalist itemtemplate内的控件 - How to find a control located inside datalist itemtemplate 如何绑定数据列表控件的itemtemplate字段内的dropdownlist - how to bind dropdownlist which is inside the itemtemplate field of datalist control 如何在Page_Load事件上找到位于数据列表itemtemplate内的控件? - How to find a control located inside datalist itemtemplate, on a Page_Load event? 如何访问放置在GridView的ItemTemplate内的图像控件的ImageUrl属性 - How to access ImageUrl property of the Image Control placed inside a ItemTemplate in the GridView 如何停止数据列表项目模板中的页面跳转复选框? - How to stop page jumping checkbox check which is inside the datalist itemtemplate? 如何在数据上有条件地修改DataList&gt; ItemTemplate内部的标记/模板? - how to modify markup/template inside of DataList>ItemTemplate conditionally on data? 如何访问ItemTemplate中的控件 - How to access controls inside an ItemTemplate asp.net用户控件,让htmlAnchor解析为href =“#” - asp.net user control, getting htmlAnchor resolve to href=“#” 如何访问另一个DataList中的DataList中的Label - How to access Label inside DataList which is inside another DataList 使用ItemTemplate(中继器)内部的自定义控件,如何访问中继器项目中的值? - With a custom control that's inside of an ItemTemplate (Repeater), how can I access values from the repeater item?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM