This is a migrated thread and some comments may be shown as answers.

Accessing Image Control in Radlistview

2 Answers 125 Views
ListView
This is a migrated thread and some comments may be shown as answers.
K W
Top achievements
Rank 1
K W asked on 19 May 2014, 10:47 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 19 May 2014, 12:28 PM
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.
0
K W
Top achievements
Rank 1
answered on 19 May 2014, 01:01 PM
Worked great. Thank you very much!
Tags
ListView
Asked by
K W
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
K W
Top achievements
Rank 1
Share this question
or