Accessing Image Control in Radlistview

3 posts, 1 answers
  1. K W
    K W avatar
    9 posts
    Member since:
    May 2010

    Posted 19 May 2014 Link to this post

    I need to access an image control (img1) which nests within a second table in my Radlistview. Is this possible to do via ItemDatabound.
    Here is the Radlistview:
     
    <telerik:RadListView ID="radlist1" runat="server" ItemPlaceholderID="ListViewContainer" DataKeyNames="ID">
        <LayoutTemplate>
                <asp:PlaceHolder runat="server" ID="ListViewContainer"></asp:PlaceHolder>
        </LayoutTemplate>
           <ItemTemplate>
                <fieldset>
                      <legend><strong><%# Eval("Name")%></strong></legend>
                            <table >
                                 <tr>
                                     <td>
                                            <table >
                                                  <td>
                                                       <strong> <%# Eval("Title")%></strong> 
                                                   </td>
                                                    <td valign="top" style="width:52px;" >
                                                          <asp:Image ID="img1" runat="server"  />
                                                      </td>
                                                </table>
                                        </td>
                                    </tr>
                                     <tr>
                                     </tr>
                                 </table>
                            </fieldset>
                        </ItemTemplate>
                 </telerik:RadListView>
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 May 2014 in reply to K W Link to this post

    Hi,

    Please try the following code snippet to access the ItemTemplate control of RadListView in 'OnItemDataBound' event. 

    C#:
    protected void RadListView1_ItemDataBound(object sender, RadListViewItemEventArgs e)
    {
        if (e.Item is RadListViewDataItem)
        {
            RadListViewDataItem item = e.Item as RadListViewDataItem;
            Image imageItem= (Image)item.FindControl("img1");//accessing image control
            //your code
        }
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. K W
    K W avatar
    9 posts
    Member since:
    May 2010

    Posted 19 May 2014 in reply to Princy Link to this post

    Worked great. Thank you very much!
Back to Top