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

RadlistView ItemTemplate button click not firing

1 Answer 238 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Abdul Kadar
Top achievements
Rank 1
Abdul Kadar asked on 11 Apr 2016, 02:26 PM

Hi

I am using a RADBUTTON in the itemtemplate of Radlistview.

Kindly let me know how to add the click-event for that RADbutton on server-side and perform the below operations

1) While clicking the RADBUTTON, : Need to store the bookid of the selected item in the Session 

2) Then redirect to cartpage.aspx (After storing the id in the session)

Pls guide how to achieve this scenario

 

            <telerik:RadListView ID="RadListView1" runat="server" ItemPlaceholderID="ProductItemContainer"

                DataKeyNames="BookID"  OnNeedDataSource="RadListView1_NeedDataSource" >
                <LayoutTemplate>
                    <fieldset>
                           <table>
  <tr>
<td>
<asp:Panel ID="ProductItemContainer" runat="server">
</asp:Panel>                                
</td>

</tr>
</table>
</fieldset>
</LayoutTemplate>
<ItemTemplate>
<fieldset>

<table>
<tr>
<td class="productItem">
    <a href="default2.aspx?isbn=<%# Eval("BookID")%>">
<img src="<%# Eval("imageurl")%>" alt="#= BookName #" />
                                   </a>
</td>

</tr>
<tr>
<td>
 <%# Eval("BookName")%> 
</td>
</tr>
<tr>
<td>
<telerik:RadButton CommandName="Button1" ID="BtnAddtoCart" runat="server" Text="Add to Cart"></telerik:RadButton>
</td>
</tr>
</table>
</fieldset>
</ItemTemplate>
</telerik:RadListView>
      

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 14 Apr 2016, 12:50 PM
Hi Abdul,

You can use the OnClick event handler of the button and acquire the item ID using the GetDataKeyValue method, similar to the approach demonstrated in this section:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-raw-field-data-and-key-values

I hope this will prove helpful.

Regards,
Eyup
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
ListView
Asked by
Abdul Kadar
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or