简体   繁体   中英

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

here the datalist with linkresponder like htmlanchor control

 <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控件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM