Hi,
I am having RadListView grouped by Date. I am trying to edit/update records in RadListView. I was able to get record key value through editFormItem.GetDataKeyValue("Seq"). But unable to access the record items in either of the updateCommand or ItemCommand events. Any help , how to access the record.
Thank you.
<t:RadListView ID="rgHrs" runat="server" RenderMode="Mobile" AllowMultiFieldSorting="true"
ItemPlaceholderID="myTimeGroupContainer" DataKeyNames="Seq" AllowPaging="true"
OnNeedDataSource="rgHrs_NeedDataSource"
OnItemDataBound="rgHrs_ItemDataBound"
OnItemCommand="rgHrs_ItemCommand"
OnItemCreated="rgHrs_ItemCreated"
OnItemDeleting="rgHrs_DeleteCommand"
OnItemUpdating="rgHrs_UpdateCommand"
>
<ItemTemplate>
<div class="row">
<div class="column small-12 ">
<header> DATE </header>
<div>
<%#Eval("WORK_DT", "{0:MM/dd/yyyy}")%>
</div>
</div>
<div class="column small-12" id="wkHrsDiv" runat="server" >
<header> HOURS </header>
<div>
<%#Eval("WORK_HRS")%>
</div>
</div>
<div class="column small-12">
<header> PC </header>
<div>
<%#Eval("PAY_CODE")%>
</div>
</div>
<div class="column small-12">
<header> ST</header>
<div >
<%#Eval("ST_CODE")%>
</div>
</div>
<div class="column small-12">
<header> COMP ID </header>
<div >
<%#Eval("COMP_ID")%>
</div>
</div>
<div class="column small-12">
<header> GL ID </header>
<div >
<%#Eval("GL_ID")%>
</div>
</div>
<div class="column small-12">
<header> WORK ORDER </header>
<div>
<%#Eval("WR_ODR_NO")%>
</div>
</div>
<div class="column small-12" style="display:none"
<header> Sequence number </header>
<div>
<%#Eval("Seq")%>
</div>
</div>
</div>
<div class="row">
<div id="commentIdDiv" runat="server" class="column medium-4">
<div class="color-blue">
<header> COMMENT </header>
</div>
<div class="note">
<asp:Label ID="lblRGComment" runat="server" Text='<%# Eval("LD_COMMENT") %>' ToolTip='<%# Eval("LD_COMMENT") %>' />
</div>
</div>
<div class="column medium-4 text-right">
<asp:Button id="editButton" runat="server" ButtonType="StandardButton" CommandName="Edit"
RenderMode="Lightweight"
Text="EDIT" class="button small" >
</asp:Button>
<asp:Button id="deleteButton" runat="server" ButtonType="StandardButton" CommandName="Delete"
RenderMode="Lightweight"
Text="DELETE" class="button small" >
</asp:Button>
</div>
</div>
</ItemTemplate>
<EmptyDataTemplate>
<div class="EmptyRows">
There are no items to be displayed.
</div>
</EmptyDataTemplate>
<EditItemTemplate>
<section>
<div class="row">
<div class="column small-12 ">
<header> DATE </header>
<div>
<t:RadTextBox RenderMode="LightWeight" ID="txtWorkDt" runat="server" Text='<%#Eval("WORK_DT", "{0:MM/dd/yyyy}")%>' >
</t:RadTextBox>
</div>
</div>
<div class="column small-12" id="wkHrsDiv" runat="server" >
<header> HOURS </header>
<div>
<t:RadTextBox RenderMode="LightWeight" ID="txtWorkHrs" runat="server" Text='<%#Eval("WORK_HRS")%>'>
</t:RadTextBox>
</div>
</div>
<div class="column small-12">
<header> PC </header>
<div>
<t:RadTextBox RenderMode="LightWeight" ID="txtPayCode" runat="server" Text='<%#Eval("PAY_CODE")%>'>
</t:RadTextBox>
</div>
</div>
<div class="column small-12">
<header> ST</header>
<div >
<t:RadTextBox RenderMode="LightWeight" ID="txtStateCode" runat="server" Text='<%#Eval("ST_CODE")%>'>
</t:RadTextBox>
</div>
</div>
<div class="column small-12">
<header> COMP ID </header>
<div >
<t:RadTextBox RenderMode="LightWeight" ID="txtCompID" runat="server" Text='<%#Eval("COMP_ID")%>'>
</t:RadTextBox>
</div>
</div>
<div class="column small-12">
<header> GL ID </header>
<div >
<t:RadTextBox RenderMode="LightWeight" ID="txtGlId" runat="server" Text='<%#Eval("GL_ID")%>'>
</t:RadTextBox>
</div>
</div>
<div class="column small-12">
<header> WORK ORDER </header>
<div>
<t:RadTextBox RenderMode="LightWeight" ID="txtWorkOrder" runat="server" Text='<%#Eval("WR_ODR_NO")%>'>
</t:RadTextBox>
</div>
</div>
<div class="column small-12" style="display:none"
<header> Sequence number </header>
<div>
<t:RadTextBox RenderMode="LightWeight" ID="txtSeqMinMax" runat="server" Text='<%#Eval("Seq")%>'>
</t:RadTextBox>
</div>
</div>
</div>
<div class="row">
<div id="commentIdDiv" runat="server" class="column medium-4">
<div class="color-blue">
<header> COMMENT </header>
</div>
<div class="note">
<t:RadTextBox ID="txtRGComment" runat="server" Text='<%# Eval("LD_COMMENT") %>' ToolTip='<%# Eval("LD_COMMENT") %>'>
</t:RadTextBox>
</div>
</div>
<div class="column medium-4" >
<t:RadButton RenderMode="Lightweight" ID="btnUpdate" runat="server" Text="UPDATE" CommandName="Update">
</t:RadButton>
<t:RadButton RenderMode="Lightweight" ID="btnCancel" runat="server" Text="CANCEL" CommandName="Cancel">
</t:RadButton>
</div>
</div>
</EditItemTemplate>
<LayoutTemplate>
<ul class="accordion my-time-report" data-accordion data-allow-all-closed="true" role="tablist" data-multi-expand="true">
<asp:PlaceHolder ID="myTimeGroupContainer2" runat="server"></asp:PlaceHolder>
</ul>
</LayoutTemplate>
<GroupSeparatorTemplate>
</GroupSeparatorTemplate>
<DataGroups>
<t:ListViewDataGroup GroupField ="WORK_DT" DataGroupPlaceholderID="MyTimeGroupContainer2" SortOrder="Ascending">
<DataGroupTemplate>
<li class="accordion-item border-bottom-2x" data-accordion-item >
<a class="accordion-title" role="tab" aria-expanded="false" aira-selected="false" >
<asp:Label runat="server" ID="Label39" Text='<%# (Container as RadListViewDataGroupItem).DataGroupKey + "Daily Total Hours: " +
(Container as RadListViewDataGroupItem).AggregatesValues["WORK_HRS"].ToString() %>'>
</asp:Label>
</a>
<div class="accordion-content" data-tab-content role="tabpanel" aria-hidden="true" style="display:none;">
<asp:PlaceHolder ID="myTimeGroupContainer" runat="server"></asp:PlaceHolder>
</div>
</li>
</DataGroupTemplate>
<GroupAggregates>
<telerik:ListViewDataGroupAggregate Aggregate="Sum" DataField="WORK_HRS" />
</GroupAggregates>
</t:ListViewDataGroup>
</DataGroups>
</t:RadListView>
Backend:
protected void rgHrs_UpdateCommand(object sender, RadListViewCommandEventArgs e)
{
try
{
// unable to access through editable item record.
RadListViewEditableItem editFormItem = (RadListViewEditableItem)e.ListViewItem;
Label stxtWorkHrs = new Label();
stxtWorkHrs = (Label)editFormItem.FindControl("WORK_HRS");
--
--
--
MyTime.UpdateTimeSheet(iCompID, sEmpID, Date, Hrs, Comment, etc....); // manual update to database..
}
catch (Exception ex)
{
DataHelper.LogErrors(ex);
throw ex;
}
}