<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ListViewIssue.aspx.cs"
Inherits="RadGridSave.ListViewIssue" %>
<%@ Register Assembly="Telerik.Web.UI, Version=2011.1.413.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
div
>
<
telerik:RadListView
ID
=
"RadListView1"
runat
=
"server"
AllowMultiItemEdit
=
"true"
onprerender
=
"RadListView1_PreRender"
>
<
ItemTemplate
>
Readonly</
ItemTemplate
>
<
EditItemTemplate
>
Edit</
EditItemTemplate
>
</
telerik:RadListView
>
</
div
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
onclick
=
"RadButton1_Click"
Text
=
"RadButton"
>
</
telerik:RadButton
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Collections.Generic;
using
Telerik.Web.UI;
namespace
RadGridSave
{
public
partial
class
ListViewIssue : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
RadListView1.DataSource =
new
List<
int
>() { 1, 2 };
}
protected
void
RadListView1_PreRender(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
foreach
(RadListViewDataItem item
in
RadListView1.Items)
{
item.Edit =
true
;
}
RadListView1.Rebind();
}
}
protected
void
RadButton1_Click(
object
sender, EventArgs e)
{
foreach
(var item
in
RadListView1.EditItems)
{
item.FireCommandEvent(RadListView.UpdateCommandName,
string
.Empty);
}
}
}
}
8 Answers, 1 is accepted
Please find the attached sample illustrating how you can implement batch updates with the RadListView control. Give it a try and let me know how it goes.
Kind regards,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Sorrry for the late request but I am struggling with the following situation that seems similar.
I have a RadListView, and NeedsDataSource that provides the data. It is used to populate a complex (?) user control that presents the data in a formatted way for review and edit. The items are assigned through properties on the UserControl, like this:
...
..
<
asp:Panel
ID
=
"DocumentDetailsArea"
runat
=
"server"
CssClass
=
"dv-document-detail-area RadAjaxPanel RadAjaxPanel-full flex-col justify-start order-2 "
>
<
telerik:RadListView
ID
=
"DocumentList1"
runat
=
"server"
CssClass
=
"dv-radlistview-area flex flex-row w-full order-1"
OnNeedDataSource
=
"DocumentList1_NeedDataSource"
AllowPaging
=
"True"
ItemPlaceholderID
=
"DocumentList1PlaceHolder1"
DataKeyNames
=
"Doc_Key"
RenderMode
=
"Lightweight"
>
<
LayoutTemplate
>
<%--<
div
id
=
"dv-layout-template-area"
class
=
"flex flex-col justify-start border-gray-100 border-solid p-2"
>--%>
<
fieldset
class
=
"w-full"
id
=
"DocumentList1"
>
<
legend
></
legend
>
<
asp:PlaceHolder
runat
=
"server"
ID
=
"DocumentList1PlaceHolder1"
></
asp:PlaceHolder
>
</
fieldset
>
<%--</
div
>--%>
</
LayoutTemplate
>
<%-- <
ItemStyle
CssClass
=
"block px-1"
></
ItemStyle
>--%>
<
ItemTemplate
>
<
div
class
=
"flex flex-col w-full order-1"
>
<
uc1:SingleDocView
ID
=
"SingleDocView1"
runat
=
"server"
DocKey='<%#Eval("doc_key") %>'
KdotblpDocumentsGd='<%#Eval("kdotblpdocumentsgd") %>'
DocType='<%#Eval("doc_type_key") %>'
DocSubType='<%#Eval("doc_subtype_key") %>'
DocSubTypeLabel='<%#Eval("sub_type") %>'
DocLevel='<%#Eval("doc_level") %>'
DocUrl='<%#Eval("target_file_name") %>'
ThumbnailUrl='<%#Eval("thumb_file_name") %>'
UploadedDtTmStamp='<%#Eval("uploaded_at") %>'
ModifiedDtTmStamp='<%#Eval("updated_at") %>'
UploadedBy='<%#Eval("uploaded_by") %>'
UpdatedBy='<%#Eval("updated_by") %>'
Title='<%#Eval("doc_title") %>'
Editable='<%#Eval("editable") %>'
Selectable='<%#Eval("selectable") %>'
LRDate='<%#Eval("doc_effective_date") %>'
LRProject='<%#Eval("doc_project_number") %>'
LRSource='<%#Eval("doc_source") %>'
DocSourceEventGd='<%#Eval("docsourceeventgd") %>'
NotesLabel="Document Notes"
Notes='<%#Eval("notes") %>'
ShowNotes="1" />
<%--DocumentNotesEditingPanel.TbxNotes.Text='<%#Eval("notes") %>'--%>
<
hr
class
=
"form-divider-line flex flex-row visible w-full py-1 order-2"
></
hr
>
</
div
>
</
ItemTemplate
>
<
ItemSeparatorTemplate
>
</
ItemSeparatorTemplate
>
<
EmptyDataTemplate
>
<%-- <
hr
class
=
"form-divider-line"
/>--%>
<
div
class
=
"flex flex-col justify-center h-12 my-2 ml-4"
>
<
div
class
=
"flex flex-row text-left space-x-1"
>
<
i
class
=
"fas fa-hand-point-up fa-2x button-icon button-icon-blue"
></
i
><
span
class
=
"text-sm"
>Click on a link to view documents for each type.</
span
>
</
div
>
</
div
>
</
EmptyDataTemplate
>
</
telerik:RadListView
>
</
asp:Panel
>
So the data gets to the properties of the usercontrol fine, but I cannot figure out how to extract the values from the user control and use them to update the columns of the original row(s). Any sort of hint would be welcome.
Hi Allen,
The RadListView exposes EditItemTemplate which is the recommended one to use when editing entities, see Edit and Insert.
As for manual handling the Edit operations you may find it useful to review our Manual data editing demo.
In general, the bulk editing goes beyond the built-in functionalities of the RadListView. However, the sampling approach suggested by Iana in this forum thread demonstrates one way to achieve such behavior by enabling multi-item edit (AllowMultiItemEdit="true") and turning all loaded items into edit mode before rendering. The same approach can be applied to editing using WebUserControl.
I have attached a sample project for you to test. It is based on the same approach as the sample shared by Iana. Feel free to modify the sample so that it fits the current scenario.
Please let me know if any further questions come up!
Kind regards,
Doncho
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
That's right Allen!
In general, Bind is suitable for use in EditItemTemplate as it will pass the value to the Update method of the data source.
You can research the difference between using Eval and Bind in multiple public resources.
Here is a StackOverflow thread about this topic - Understanding ASP.NET Eval() and Bind().
Kind regards,
Doncho
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hi Allen,
The sample project I have provided earlier demonstrates a custom approach and, in its essence, it forces the RadListView control to always display all its items into edit mode. The ItemTemplate in this approach is not used at all and it can be blank. Please note that the WebUserControl is only used in the EditItemTemplate:
<ItemTemplate></ItemTemplate>
<EditItemTemplate>
<div class="listview-item editform">
<uc1:WebUserControl runat="server" ID="WebUserControl"
ShipName='<%# Bind("ShipName") %>'
ShipCountry='<%# Bind("ShipCountry") %>' />
</div>
</EditItemTemplate>
A UserControl may contain input controls that would be needed for editings like TextBox, DropDownList, DatePicker, etc... On the other hand, such controls are usually avoided for displaying data as they provide editing functionalities. As for the ItemTemplate, it is designed for displaying data in read-only mode. If a WebUserControl is used inside the ItemTemplate it normally would contain Labels, Literals, and other read-only controls. That comes to say that in standard use cases the ItemTemplate and the EditItemTemplate would contain different controls hence the same WebUserControl can hardly be applicable for both of the control containers.
I hope this will help you get a better overview.
Kind regards,
Doncho
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.