I have a RadListView with edit and delete buttons in the template. What I want is that when one clicks edit that the page does a post back. If the delete is clicked I want to perform a ajax to delete the item and rebind the templete. I have tried different ways to achieve this. The biggest problem is that unlike the RadGrid there is no client OnCommand for me to inspect the commands for postback. If I had this I could cancel the ajax call and force a postback for the edit. The closest I have gotten is with the code below, but unfortunately it seems that depending on the order of the settings of the ajaxsettings one button will not work or perform the ajax or postback call. Any suggestions would be appreciated it.
This causes the Edit button to not work. despite it being not set for ajax.
This causes the Edit button to not work. despite it being not set for ajax.
<telerik:RadListView ID="rlvCustomerProfile_Contacts" runat="server" |
ItemPlaceholderID="ContactsContainer" |
OnNeedDataSource="rlvCustomerProfile_Contacts_NeedDataSource" |
OnItemDataBound="rlvCustomerProfile_Contacts_ItemDataBound"> |
<LayoutTemplate> |
<asp:PlaceHolder ID="ContactsContainer" runat="server"></asp:PlaceHolder> |
</LayoutTemplate> |
<ItemTemplate> |
<table cellspacing="0" cellpadding="4" class="ContentTableBordered TableFullWidth"> |
<tr> |
<td class="ContentTableCellTitleMedium" colspan="8"> |
<table width="100%" cellpadding="0" cellspacing="0" style="margin:0px 0px 0px 0px;" border="0"> |
<tr> |
<td> |
<asp:Label ID="lblLastNameTitle" runat="server" CssClass="LabelBold" Text='<%# Eval("LastName") %>'></asp:Label>, <asp:Label ID="lblFirstNameTitle" runat="server" CssClass="LabelBold" Text='<%# Eval("FirstName") %>'></asp:Label> |
</td> |
<td align="right"> |
<asp:Button ID="btnEdit" runat="server" |
CommandArgument='<%# Eval("CustomerContactId") %>' |
Text="Edit" |
OnClick="btnCustomerProfile_EditContact_Click" |
OnClientClick="alert('test');Master_DoPostBackInstead=true;" /> |
<asp:Button ID="btnDelete" runat="server" |
CommandArgument='<%# Eval("CustomerContactId") %>' |
Text="Delete" |
OnClick="btnCustomerProfile_DeleteContact_Click" |
ValidationGroup="vgContactDelete" /> |
</td> |
</tr> |
</table> |
etc..... |
protected void rlvCustomerProfile_Contacts_ItemDataBound(object sender, RadListViewItemEventArgs e) |
{ |
if (e.Item.ItemType == RadListViewItemType.DataItem) |
{ |
Button delete = e.Item.FindControlRecursive("btnDelete") as Button; |
if (delete != null) SiteMasterPage.MasterAjaxManager.AjaxSettings.AddAjaxSetting(delete, rlvCustomerProfile_Contacts, SiteMasterPage.MainLoadingPanel); |
} |
} |