c# - Can't call controls in ItemTemplate -
i have listview element has itemtemplate within has image element within can't access in code reason, way this?
<div class="container"> <asp:listview id="listview1" runat="server"> <itemtemplate> <div class="col-sm-6 col-md-4"> <div class="thumbnail"> <h4><%# eval("colour") + " " + eval("make") + " " + eval("model") + " " + "(" + eval("type") + ")"%></h4> <asp:image id="image1" class="main" runat="server" /> <div class="caption"> <h4><div class="title"> seller: </div><%# eval("first_name") + " " + eval("last_name")%></h4> <h4><div class="title"> location: </div><%# eval("city") %></h4> <h4><div class="title"> year of reg: </div><%# eval("year") %></h4> <h4><div class="title"> price: </div><%# "£" + eval("price") %></h4> </div> </div> </div> </itemtemplate> </asp:listview> </div>
i trying call image1 in code.
i want access on click event, id not showing when try access control, here click event:
protected void btn_search_click(object sender, eventargs e) { }
you need know index of listview item want access image, can following:
listview1.items[0].findcontrol("image1") image;
Comments
Post a Comment