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

Radlistview with image button

5 Answers 192 Views
ListView
This is a migrated thread and some comments may be shown as answers.
ahmed
Top achievements
Rank 1
ahmed asked on 08 Jan 2014, 05:47 PM
Hello
i added asp image and image buttons in rad list view read from DB source
my problem i cant get selected picture form rad button to so image
  <asp:Image ID="Image1" runat="server" Width="300px" />
                    <br />
                    <telerik:RadListView ID="RadListView3" runat="server" AllowPaging="True"
                    onselectedindexchanged="RadListView3_SelectedIndexChanged"
                      OnItemDataBound="RadListView3_ItemDataBound" PageSize="4"
                      AllowCustomPaging="True" Skin="Vista">
                        <LayoutTemplate>
                            <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <asp:ImageButton ID="ImageButton2" runat="server" Height="80px"
                                ImageUrl='<%# Eval("Pic_Path") %>' onclick="ImageButton2_Click" Width="60px" />
                        </ItemTemplate>
                    </telerik:RadListView>

can you help me ??

5 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 13 Jan 2014, 01:41 PM
Hi Ahmed,

Based on the provided description I'm not completely sure what exactly is the issue you are facing. Are you truing to get the RadListView selected item on a external button click?
If this your case you could use the approach below:
protected void Button1_Click(object sender, EventArgs e)
    {
        foreach (RadListViewItem item in RadListView3.SelectedItems)
        {
            ImageButton btn= (ImageButton ) item.FindControl("ImageButton2");
           
        }
    }

I hope this helps.

Regards,
Maria Ilieva
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
ahmed
Top achievements
Rank 1
answered on 14 Jan 2014, 09:42 AM
when try RadListView3.SelectedItems.Count; always = 0
cause that i cant enter loop

ImageButton btn = (ImageButton)item.FindControl("ImageButton2");

                Image1.ImageUrl = btn.ImageUrl;


how can set selecteditem is clicked image ??

0
Maria Ilieva
Telerik team
answered on 14 Jan 2014, 12:42 PM
Hi Ahmed,

You could set a CommandName for the specific ImageButton and in the RadListView ItemCommand event manually select the item. For example:
protected void RadListView3_ItemCommand(object sender, Telerik.Web.UI.RadListViewCommandEventArgs e)
{
  if (e.CommandName == "CommandName")
  {
     RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;
     item.Selected = true;
  }
 }

I hope this helps.

Regards,
Maria Ilieva
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
ahmed
Top achievements
Rank 1
answered on 14 Jan 2014, 04:55 PM
hello Maria

can you help me in that issue

i have radlistview contains image button & normal image
i need when press on image button that image shown in image

thank you for your support
0
Maria Ilieva
Telerik team
answered on 15 Jan 2014, 01:52 PM
Hi Ahmed,

You could review the Image Gallery approach for showing images in RadListView control presented in the online demo below:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/listviewsliderwindowrotator/defaultcs.aspx?product=listview

Regards,
Maria Ilieva
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
ListView
Asked by
ahmed
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
ahmed
Top achievements
Rank 1
Share this question
or