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

Exporting from RadGrid within a RadAjaxPanel

8 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 09 Jan 2012, 06:16 AM
I have been struggling for some time to get Exporting to work under Ajax with mixed results. I have finally identified what works and what doesn't.
I have a Grid and in CommandItemSettings I set some ShowExport..Buttons to true. This works fine when not using Ajax. But ceases to work with Ajax. I am using ItemCreated to trap GridCommanItem creation and I search for, and successfully find the buttons named ExportToXxxButton and then I use ScriptManager1.RegisterPostBackControl(button) for each button, but it makes no difference.
However, if I make a Button dynamically and add it to the GridCommanItem using item.Controls[0].Controls[0].Controls[0].Controls[0].Controls.AddAt(0, b); And then register that button with ScriptManager, it works. So there is something with the way the standard buttons are defined that stops them from working.

Is there a fix for this or a workaround? I like using the standard buttons.

Additionally, the documentation mentions methods ExportToExcel2007 and ExportToWord2007 but neither shows up in my intellisense.

As I mentioned in an earlier post, I believe there should be methods provided for adding Controls to the GridCommanItem in a way that doesn't hard code the 4 Controls[0].

8 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 09 Jan 2012, 06:27 AM
Hello,

<script type="text/javascript">
       function onRequestStart(sender, args)
       {
           if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||
                   args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||
                   args.get_eventTarget().indexOf("ExportToCsvButton") >= 0)
           {
               args.set_enableAjax(false);
           }
       }
   </script>

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="onRequestStart" >
....................
// grid code
...................
 </telerik:RadAjaxManager>

Let me know if any concern.


Thanks,
Jayesh Goyani
0
Martin
Top achievements
Rank 1
answered on 09 Jan 2012, 05:18 PM
Thank you, That works. But I was really interested in why it doesn't work with the following code in the code behind...
string[] buttonNames = { "ExportToWordButton", "ExportToPdfButton", "ExportToExcelButton", "ExportToCsvButton" };
RadScriptManager sm = (RadScriptManager) Page.Master.FindControl("sm1");
foreach (string s in buttonNames)
{
    Button button = (Button)item.FindControl(s);
    if (button != null)
        sm.RegisterPostBackControl(button);
}

The above code works if the button isn't produced by the standard code, i.e., ShowExportToWordButton="true"

Also, any word on the Methods ExportToExcel2007 and ExportToWord2007?
0
Shinu
Top achievements
Rank 2
answered on 10 Jan 2012, 05:12 AM
Hello Martin,

The exporting feature of the control work with regular postbacks only. If you have ajaxified your RadGrid, disable its ajax mode to export with regular postback. Check the following help documentation which explains more about this.
Export from Ajaxified Grid.

-Shinu.
0
Martin
Top achievements
Rank 1
answered on 10 Jan 2012, 09:07 PM
You would do well to read your documentation before quoting it.

Here is the part that is either wrong or confusing...

It is also possible to register the control as a trigger for postback in code-behind:

ScriptManager.GetCurrent(Page).RegisterPostBackControl(btnExport);
This EXPLICITLY says that the control can be registered as a PostBack Control. My original statement was that it worked for normal buttons, but not for the built in buttons. So either the documentation is wrong, or there is a bug. Fix one or the other.
0
Mark
Top achievements
Rank 1
answered on 19 Dec 2013, 06:01 PM
Jayesh / Telerik, 

The code you provided allows the RadGrid within the RadAjaxPanel start the export process.  It now kicks out an error of:

Specified argument was out of the range of valid values.
Parameter name: index


Line 44:                     Dim cell As TableCell = nestedView.ParentItem("ExpandColumn")
Line 45: 
Line 46:                     cell.Controls(0).Visible = False
Line 47:                     cell.Text = " "
Line 48:                     nestedViewItem.Visible = False

Any suggestions?  Thanks!
0
Jayesh Goyani
Top achievements
Rank 2
answered on 21 Dec 2013, 05:06 AM
Hello,

Can you please provide full your code block?

Thanks,
Jayesh Goyani
0
Mark
Top achievements
Rank 1
answered on 21 Dec 2013, 05:04 PM
I have included the ASPX then the VB file afterwards.  Thanks for your help.


<%@ Page Title="" Language="VB" MasterPageFile="~/Job/Job.master" AutoEventWireup="false" CodeFile="JobLabor.aspx.vb" Inherits="Timecard_JobLabor" %>
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
 
      <style type="text/css">
.RadGrid_Default{border:1px solid #828282;background-color:white;color:#333;font-family:"Segoe UI",Arial,Helvetica,sans-serif;font-size:12px;line-height:16px}.RadGrid_Default{border:1px solid #828282;background-color:white;color:#333;font-family:"Segoe UI",Arial,Helvetica,sans-serif;font-size:12px;line-height:16px}.RadGrid_Default .rgMasterTable{font-family:"Segoe UI",Arial,Helvetica,sans-serif;font-size:12px;line-height:16px}.RadGrid .rgMasterTable{border-collapse:separate;border-spacing:0}.RadGrid_Default .rgMasterTable{font-family:"Segoe UI",Arial,Helvetica,sans-serif;font-size:12px;line-height:16px}.RadGrid .rgMasterTable{border-collapse:separate;border-spacing:0}.RadGrid_Default .rgCommandRow{background:#c5c5c5 0 -2099px repeat-x url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif');color:#000}.RadGrid_Default .rgCommandRow{background:#c5c5c5 0 -2099px repeat-x url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif');color:#000}.RadGrid_Default .rgCommandCell{border:1px solid;border-color:#999 #f2f2f2;border-top-width:0;padding:0}.RadGrid_Default .rgCommandCell{border:1px solid;border-color:#999 #f2f2f2;border-top-width:0;padding:0}.RadGrid_Default .rgCommandTable{border:0;border-top:1px solid #fdfdfd;border-bottom:1px solid #e7e7e7}.RadGrid_Default .rgCommandTable{border:0;border-top:1px solid #fdfdfd;border-bottom:1px solid #e7e7e7}.RadGrid_Default .rgAdd{margin-right:3px;background-position:0 -1650px}.RadGrid_Default .rgAdd{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgAdd{width:18px;height:18px;vertical-align:bottom}.RadGrid .rgAdd{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgAdd{margin-right:3px;background-position:0 -1650px}.RadGrid_Default .rgAdd{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgAdd{width:18px;height:18px;vertical-align:bottom}.RadGrid .rgAdd{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgSave{background-position:0 -1825px;height:18px;width:18px}.RadGrid_Default .rgSave{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgSave{margin:0 3px 0 10px}.RadGrid .rgSave{background-position:0 -1825px;height:18px;width:18px}.RadGrid .rgSave{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgSave{background-position:0 -1825px;height:18px;width:18px}.RadGrid_Default .rgSave{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgSave{margin:0 3px 0 10px}.RadGrid .rgSave{background-position:0 -1825px;height:18px;width:18px}.RadGrid .rgSave{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgCancel{background-position:0 -1850px}.RadGrid_Default .rgCancel{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgCancel{width:18px;height:18px}.RadGrid .rgCancel{margin:0 3px 0 10px}.RadGrid .rgCancel{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgCancel{background-position:0 -1850px}.RadGrid_Default .rgCancel{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgCancel{width:18px;height:18px}.RadGrid .rgCancel{margin:0 3px 0 10px}.RadGrid .rgCancel{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgRefresh{margin-right:3px;background-position:0 -1600px}.RadGrid_Default .rgRefresh{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgRefresh{width:18px;height:18px;vertical-align:bottom}.RadGrid .rgRefresh{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgRefresh{margin-right:3px;background-position:0 -1600px}.RadGrid_Default .rgRefresh{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgRefresh{width:18px;height:18px;vertical-align:bottom}.RadGrid .rgRefresh{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgExpXLS{background-position:0 0}.RadGrid_Default .rgExpXLS{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Common.Grid.export.gif')}.RadGrid_Default .rgExpXLS{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgExpXLS{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgExpXLS{background-position:0 0}.RadGrid_Default .rgExpXLS{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Common.Grid.export.gif')}.RadGrid_Default .rgExpXLS{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgExpXLS{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgExpPDF{background-position:0 -100px}.RadGrid_Default .rgExpPDF{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Common.Grid.export.gif')}.RadGrid_Default .rgExpPDF{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgExpPDF{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgExpPDF{background-position:0 -100px}.RadGrid_Default .rgExpPDF{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Common.Grid.export.gif')}.RadGrid_Default .rgExpPDF{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgExpPDF{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgExpCSV{background-position:0 -150px}.RadGrid_Default .rgExpCSV{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Common.Grid.export.gif')}.RadGrid_Default .rgExpCSV{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgExpCSV{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgExpCSV{background-position:0 -150px}.RadGrid_Default .rgExpCSV{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Common.Grid.export.gif')}.RadGrid_Default .rgExpCSV{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgExpCSV{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgExpDOC{background-position:0 -50px}.RadGrid_Default .rgExpDOC{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Common.Grid.export.gif')}.RadGrid_Default .rgExpDOC{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgExpDOC{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgExpDOC{background-position:0 -50px}.RadGrid_Default .rgExpDOC{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Common.Grid.export.gif')}.RadGrid_Default .rgExpDOC{background-image:url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgExpDOC{width:16px;height:16px;border:0;margin:0;padding:0;background-color:transparent;background-repeat:no-repeat;vertical-align:middle;font-size:1px;cursor:pointer}.RadGrid_Default .rgHeaderWrapper{border:0;border-bottom:1px solid #828282;background:#eaeaea 0 -2300px repeat-x url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid_Default .rgHeaderWrapper{border:0;border-bottom:1px solid #828282;background:#eaeaea 0 -2300px repeat-x url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid_Default .rgHeaderDiv{background:#eee 0 -7550px repeat-x url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid_Default .rgHeaderDiv{background:#eee 0 -7550px repeat-x url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid table.rgMasterTable tr .rgExpandCol{padding-left:0;padding-right:0;text-align:center}.RadGrid table.rgMasterTable tr .rgExpandCol{padding-left:0;padding-right:0;text-align:center}.RadGrid .rgClipCells .rgHeader{overflow:hidden}.RadGrid .rgClipCells .rgHeader{overflow:hidden}.RadGrid_Default .rgHeader{color:#333}.RadGrid_Default .rgHeader{border:0;border-bottom:1px solid #828282;background:#eaeaea 0 -2300px repeat-x url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgHeader{padding-top:5px;padding-bottom:4px;text-align:left;font-weight:normal}.RadGrid .rgHeader{padding-left:7px;padding-right:7px}.RadGrid .rgHeader{cursor:default}.RadGrid_Default .rgHeader{color:#333}.RadGrid_Default .rgHeader{border:0;border-bottom:1px solid #828282;background:#eaeaea 0 -2300px repeat-x url('mvwres://Telerik.Web.UI, Version=2013.2.611.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif')}.RadGrid .rgHeader{padding-top:5px;padding-bottom:4px;text-align:left;font-weight:normal}.RadGrid .rgHeader{padding-left:7px;padding-right:7px}.RadGrid .rgHeader{cursor:default}.RadGrid_Default .rgMasterTable > tbody > tr.rgCommandRow .rgCommandCell{border-top-width:1px;border-bottom-width:0}.RadGrid_Default .rgMasterTable > tbody > tr.rgCommandRow .rgCommandCell{border-top-width:1px;border-bottom-width:0}
        </style>
    <script type="text/javascript">
        function onRequestStart(sender, args) {
            if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||
                    args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||
                    args.get_eventTarget().indexOf("ExportToCsvButton") >= 0) {
                args.set_enableAjax(false);
            }
        }
   </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <br />
    <telerik:RadFilter ID="RadFilter1" runat="server"  FilterContainerID="gvCrewMemberLabor1">
        <FieldEditors>
            <telerik:RadFilterDateFieldEditor DataType="System.DateTime" DisplayName="Work Date" FieldName="WorkDate" />
            <telerik:RadFilterDropDownEditor DataSourceID="WorkerDataSource" DataTextField="Full_Name" DataValueField="ID" DisplayName="Worker Name" FieldName="Worker" />
        </FieldEditors>
    </telerik:RadFilter>
    <br />
    <asp:Button ID="btnApproveAll" runat="server" Text="Approve All" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
 
    
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="onRequestStart">
 
    <telerik:RadGrid ID="gvCrewMemberLabor1" runat="server" AllowSorting="True" CellSpacing="0" GridLines="None" ShowFooter="True" DataSourceID="JobPricingDataSource" EnableHierarchyExpandAll="True" AutoGenerateColumns="False" ShowStatusBar="True" AllowPaging="True">
        <GroupingSettings NestedTableCaption="Crew Members" />
        <ExportSettings ExportOnlyData="True">
            <Pdf AllowPrinting="False">
            </Pdf>
        </ExportSettings>
        <ClientSettings AllowKeyboardNavigation="True">
            <Selecting AllowRowSelect="True" />
            <KeyboardNavigationSettings AllowSubmitOnEnter="True" />
            <Scrolling AllowScroll="True" UseStaticHeaders="True" EnableVirtualScrollPaging="True" />
        </ClientSettings>
        <MasterTableView AllowMultiColumnSorting="True" CommandItemDisplay="TopAndBottom" DataKeyNames="ID" ShowFooter="False" DataSourceID="JobPricingDataSource" HierarchyLoadMode="ServerBind" EnableHierarchyExpandAll="False" ClientDataKeyNames="ID" Name="TopLevel" EditMode="PopUp">
            <DetailTables>
                <telerik:GridTableView runat="server" DataKeyNames="ID" DataSourceID="JobPriceSubDataSource" HierarchyDefaultExpanded="True" CommandItemDisplay="Top" ClientDataKeyNames="ID" Name="CrewDetails" EditMode="PopUp">
                    <CommandItemSettings ExportToPdfText="Export to PDF" ShowExportToCsvButton="True" ShowExportToExcelButton="True" ShowExportToPdfButton="True" ShowExportToWordButton="True" />
                    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                        <HeaderStyle Width="20px" />
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True" Created="True">
                        <HeaderStyle Width="20px" />
                    </ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" FilterControlAltText="Filter EditCommandColumn column">
                        </telerik:GridEditCommandColumn>
                        <telerik:GridBoundColumn DataField="Job_OtherID" FilterControlAltText="Filter JobID column" HeaderText="Job #" SortExpression="Job_OtherID" UniqueName="JobID">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridDropDownColumn DataSourceID="WorkerDataSource" FilterControlAltText="Filter Worker column" HeaderText="Worker" ListTextField="Full_Name" ListValueField="ID" UniqueName="Worker" DataField="Worker" SortExpression="Worker">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridDropDownColumn>
                        <telerik:GridDropDownColumn DataSourceID="WorkCodeDataSource" FilterControlAltText="Filter WorkType2 column" HeaderText="Work Type" ListTextField="WorkCodeDescription" ListValueField="WorkCode" UniqueName="WorkType" DataField="WorkType" SortExpression="WorkType">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridDropDownColumn>
                        <telerik:GridDateTimeColumn DataField="WorkDate" FilterControlAltText="Filter WorkDate column" HeaderText="Work Date" UniqueName="WorkDate">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridDateTimeColumn>
                        <telerik:GridDateTimeColumn DataField="StartedOn" FilterControlAltText="Filter StartedOn column" HeaderText="Started At" PickerType="TimePicker" UniqueName="StartedOn">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridDateTimeColumn>
                        <telerik:GridDateTimeColumn DataField="EndedOn" FilterControlAltText="Filter EndOn column" HeaderText="Ended At" PickerType="TimePicker" UniqueName="EndOn">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridDateTimeColumn>
                        <telerik:GridBoundColumn DataField="ManualHRSdec" FilterControlAltText="Filter Hours column" HeaderText="Hours" SortExpression="ManualHRSdec" UniqueName="ManualHRSdec">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Units" FilterControlAltText="Filter Units column" HeaderText="Units" SortExpression="Units" UniqueName="Units">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridDropDownColumn DataField="BillType" DataSourceID="BillTypeDataSource" FilterControlAltText="Filter BillType column" HeaderText="Bill Type" ListTextField="PricingType" ListValueField="ID" SortExpression="BillType" UniqueName="BillType">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridDropDownColumn>
                        <telerik:GridBoundColumn DataField="Rate" FilterControlAltText="Filter Rate column" HeaderText="Rate" SortExpression="Rate" UniqueName="Rate" DataFormatString="{0:c}">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="AdjustedRate" FilterControlAltText="Filter AdjustedRate column" HeaderText="Adj Rate" SortExpression="AdjustedRate" UniqueName="AdjustedRate" DataFormatString="{0:c}">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="LineRate" FilterControlAltText="Filter LineRate column" HeaderText="Line Rate" SortExpression="LineRate" UniqueName="LineRate" DataFormatString="{0:c}">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Comments" FilterControlAltText="Filter Comments column" HeaderText="Comments" SortExpression="Comments" UniqueName="Comments">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Billable" FilterControlAltText="Filter Billable column" HeaderText="Billable" SortExpression="Billable" UniqueName="Billable">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Approved" FilterControlAltText="Filter Approved column" HeaderText="Approved" SortExpression="Approved" UniqueName="Approved">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                    </Columns>
                    <EditFormSettings>
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                        </EditColumn>
                    </EditFormSettings>
                    <BatchEditingSettings EditType="Cell" />
                    <PagerStyle PageSizeControlType="RadComboBox" />
                </telerik:GridTableView>
            </DetailTables>
            <NestedViewSettings DataSourceID="JobPriceSubDataSource">
                <ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="MasterID" MasterKeyField="ID" />
                </ParentTableRelation>
            </NestedViewSettings>
            <CommandItemSettings ExportToPdfText="Export to PDF" ShowExportToCsvButton="True" ShowExportToExcelButton="True" ShowExportToPdfButton="True" ShowExportToWordButton="True">
            </CommandItemSettings>
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column" Created="True">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" FilterControlAltText="Filter EditCommandColumn column" Exportable="False">
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="Job_OtherID" FilterControlAltText="Filter JOBID column" HeaderText="Job #" SortExpression="Job_OtherID" UniqueName="JOBID" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                    <HeaderStyle Width="100px" HorizontalAlign="Center" VerticalAlign="Middle" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </telerik:GridBoundColumn>
                <telerik:GridDropDownColumn DataField="Worker" DataSourceID="WorkerDataSource" FilterControlAltText="Filter Worker column" HeaderText="Worker" ListTextField="Full_Name" ListValueField="ID" SortExpression="Worker" UniqueName="Worker">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                </telerik:GridDropDownColumn>
                <telerik:GridDropDownColumn DataField="WorkType" DataSourceID="WorkCodeDataSource" FilterControlAltText="Filter WorkCode column" HeaderText="Work Code" ListTextField="WorkCodeDescription" ListValueField="WorkCode" SortExpression="WorkType" UniqueName="WorkType" Exportable="False">
                    <ColumnValidationSettings EnableRequiredFieldValidation="True">
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                    <HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" />
                    <ItemStyle Wrap="True" HorizontalAlign="Left" VerticalAlign="Middle" />
                </telerik:GridDropDownColumn>
                <telerik:GridDateTimeColumn DataField="WorkDate" DataFormatString="{0:d}" FilterControlAltText="Filter WorkDate column" HeaderText="Work Date" SortExpression="WorkDate" UniqueName="WorkDate" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                    <HeaderStyle Width="200px" HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="200px" Wrap="False" />
                </telerik:GridDateTimeColumn>
                <telerik:GridDateTimeColumn DataField="StartedOn" DataFormatString="{0:t}" FilterControlAltText="Filter StartedOn column" HeaderText="Started At" PickerType="TimePicker" UniqueName="StartedOn" SortExpression="StartedOn" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </telerik:GridDateTimeColumn>
                <telerik:GridDateTimeColumn DataField="EndedOn" DataFormatString="{0:t}" FilterControlAltText="Filter EndedOn column" HeaderText="Ended At" PickerType="TimePicker" SortExpression="EndedOn" UniqueName="EndedOn" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </telerik:GridDateTimeColumn>
                <telerik:GridBoundColumn DataField="ManualHRSdec" DataType="System.Decimal" FilterControlAltText="Filter ManualHRSdec column" HeaderText="Hours" SortExpression="ManualHRSdec" UniqueName="Hours" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                    <HeaderStyle Width="50px" HorizontalAlign="Center" VerticalAlign="Middle" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Units" DataType="System.Decimal" FilterControlAltText="Filter Units column" HeaderText="Units" SortExpression="Units" UniqueName="Units" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                    <HeaderStyle Width="50px" HorizontalAlign="Center" VerticalAlign="Middle" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </telerik:GridBoundColumn>
                <telerik:GridDropDownColumn DataSourceID="BillTypeDataSource" FilterControlAltText="Filter BillType column" HeaderText="Bill Type" ListTextField="PricingType" ListValueField="ID" UniqueName="BillType" DataField="BillType" SortExpression="BillType" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                    <HeaderStyle Width="100px" HorizontalAlign="Center" VerticalAlign="Middle" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </telerik:GridDropDownColumn>
                <telerik:GridBoundColumn DataField="MasterID" FilterControlAltText="Filter column column" HeaderText="Master" SortExpression="MasterID" UniqueName="column" Visible="False" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Rate" FilterControlAltText="Filter Rate column" HeaderText="Rate" SortExpression="Rate" UniqueName="Rate" DataFormatString="{0:c}" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="AdjustedRate" FilterControlAltText="Filter AdjustedRate column" HeaderText="Adj Rate" SortExpression="AdjustedRate" UniqueName="AdjustedRate" DataFormatString="{0:c}" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LineRate" FilterControlAltText="Filter LineRate column" HeaderText="Line Rate" SortExpression="LineRate" UniqueName="LineRate" DataFormatString="{0:c}" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Comments" FilterControlAltText="Filter Comments column" HeaderText="Comments" SortExpression="Comments" UniqueName="Comments" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                    <HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" />
                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Billable" FilterControlAltText="Filter Billable column" HeaderText="Billable" SortExpression="Billable" UniqueName="Billable" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Approved" FilterControlAltText="Filter Approved column" HeaderText="Approved" SortExpression="Approved" UniqueName="Approved" Exportable="False">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                </telerik:GridBoundColumn>
            </Columns>
            <EditFormSettings EditFormType="WebUserControl" UserControlName="~/UserControls/AdvLaborDataEntry.ascx">
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
                <PopUpSettings Modal="True" />
            </EditFormSettings>
            <BatchEditingSettings EditType="Cell">
            </BatchEditingSettings>
            <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
        </MasterTableView>
        <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
    </telerik:RadGrid>
            <asp:Label ID="Label1" runat="server"></asp:Label>
        </telerik:RadAjaxPanel>
    <asp:SqlDataSource ID="JobPricingDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:HSIWebConnectionString %>" SelectCommand="SELECT JobPricing.ID, JobPricing.JOBID, JOBS.Job_OtherID, JobPricing.WorkDate, JobPricing.Worker, JobPricing.Rate, JobPricing.AdjustedRate, JobPricing.LineRate, JobPricing.Billable, JobPricing.Approved, JobPricing.StartedOn, JobPricing.EndedOn,UPPER( JobPricing.WorkType) as WorkType, JobPricing.ManualHRSdec, JobPricing.Units, JobPricing.Comments, JobPricing.BillType, JOBS.Job_OtherID AS JobOtherID , JOBS.Cust_Nbr as CustomerID FROM JobPricing INNER JOIN JOBS ON JobPricing.JOBID = JOBS.JOB_NBR WHERE (JobPricing.MasterID IS NULL) AND JOBID=@JobID COLLATE Latin1_General_CI_AS ">
        <SelectParameters>
            <asp:QueryStringParameter Name="JobID" QueryStringField="ID" />
        </SelectParameters>
    </asp:SqlDataSource>
 
    <asp:SqlDataSource ID="WorkCodeDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:HSIWebConnectionString %>" SelectCommand="SELECT [Work Code] as WorkCode, [Work Code] + ' ' + [Work Code Description] AS WorkCodeDescription FROM WorkCodes"></asp:SqlDataSource>
        <asp:SqlDataSource ID="BillTypeDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:HSIWebConnectionString %>" SelectCommand="SELECT [ID], [PricingType] FROM [BillingTypes]"></asp:SqlDataSource>
        <asp:SqlDataSource ID="JobPriceSubDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:HSIWebConnectionString %>" SelectCommand="SELECT JobPricing.ID, JobPricing.JOBID, JobPricing.WorkDate, JobPricing.Worker, JobPricing.StartedOn, JobPricing.EndedOn, JobPricing.WorkType, JobPricing.ManualHRSdec, JobPricing.Units, JobPricing.Comments, JobPricing.BillType, JOBS.Job_OtherID FROM JobPricing INNER JOIN JOBS ON JobPricing.JOBID = JOBS.JOB_NBR WHERE (JobPricing.MasterID = @MasterID)">
            <SelectParameters>
                <asp:Parameter Name="MasterID" Type="Int32" />
            </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="WorkerDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:HSIWebConnectionString %>" SelectCommand="SELECT [Full Name] AS Full_Name, [ID] FROM [Users]"></asp:SqlDataSource>
    <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=HSIWebEntities" DefaultContainerName="HSIWebEntities" EnableFlattening="False" EntitySetName="JobPricings" EntityTypeFilter="JobPricing" Select="" Where="it.ID >= @ID">
        <WhereParameters>
            <asp:Parameter DbType="Double" DefaultValue="31694" Name="ID" />
        </WhereParameters>
    </asp:EntityDataSource>
</asp:Content>

///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

.vb File
Imports Telerik.Web.UI
 
 
Partial Class Timecard_JobLabor
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        '  gvCrewMemberLabor1.MasterTableView.EditMode = Telerik.Web.UI.GridEditMode.EditForms
 
    End Sub
 
 
    Protected Sub gvCrewMemberLabor1_PreRender(sender As Object, e As EventArgs) Handles gvCrewMemberLabor1.PreRender
        HideExpandColumnForNonCrew(gvCrewMemberLabor1.MasterTableView)
        ' ViewState("JobOtherID") = "12345"
    End Sub
 
    Public Sub HideExpandColumnRecursive(ByVal tableView As GridTableView)
 
        Dim nestedViewItems As GridItem() = tableView.GetItems(GridItemType.NestedView)
        For Each nestedViewItem As GridNestedViewItem In nestedViewItems
            For Each nestedView As GridTableView In nestedViewItem.NestedTableViews
                If nestedView.Items.Count = 0 Then
                    Dim cell As TableCell = nestedView.ParentItem("ExpandColumn")
 
                    cell.Controls(0).Visible = False
                    cell.Text = " "
                    nestedViewItem.Visible = False
                End If
                If nestedView.HasDetailTables Then
                    HideExpandColumnRecursive(nestedView)
                End If
            Next
        Next
    End Sub
 
    Public Sub HideExpandColumnForNonCrew(ByVal tableView As GridTableView)
 
        Dim nestedViewItems As GridItem() = tableView.GetItems(GridItemType.NestedView)
        For Each nestedViewItem As GridNestedViewItem In nestedViewItems
            For Each nestedView As GridTableView In nestedViewItem.NestedTableViews
                '  lblError.Text &= nestedView.ParentItem("Worker").Text & "<BR>"
                If nestedView.ParentItem("Worker").Text <> "2 Man Crew" Then
                    Dim cell As TableCell = nestedView.ParentItem("ExpandColumn")
 
                    cell.Controls(0).Visible = False
                    cell.Text = " "
                    nestedViewItem.Visible = False
                End If
                If nestedView.HasDetailTables Then
                    HideExpandColumnRecursive(nestedView)
                End If
            Next
        Next
    End Sub
 
 
    Protected Sub gvCrewMemberLabor1_InsertCommand(sender As Object, e As GridCommandEventArgs) Handles gvCrewMemberLabor1.InsertCommand
 
        Try
            Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)
            Dim values As New Hashtable()
            ' item.ExtractValues(values)
 
            Dim userControl As UserControl = CType(e.Item.FindControl(GridEditFormItem.EditFormUserControlID), UserControl)
            If Not userControl Is Nothing Then
 
                values("Worker") = CType(userControl.FindControl("cmbWorker"), RadComboBox).SelectedValue
 
                values("Job_OtherID") = CType(userControl.FindControl("txtJobNumber"), RadTextBox).Text
 
                values("WorkDate") = CType(userControl.FindControl("dtWorkDate"), RadDatePicker).SelectedDate
 
                values("WorkType") = CType(userControl.FindControl("txtWorkCode"), RadTextBox).Text.ToUpper
 
                values("StartedOn") = CType(userControl.FindControl("dtStartedAt"), RadTimePicker).SelectedDate
 
                values("EndedOn") = CType(userControl.FindControl("dtEndedAt"), RadTimePicker).SelectedDate
 
                values("ManualHRSdec") = CType(userControl.FindControl("txtHours"), RadNumericTextBox).Text
 
                values("Units") = CType(userControl.FindControl("txtUnits"), RadNumericTextBox).Text
 
                values("BillType") = CType(userControl.FindControl("cmbBillType"), RadComboBox).SelectedValue
 
                values("Comments") = CType(userControl.FindControl("txtComments"), RadTextBox).Text
 
                values("AdjustedRate") = CType(userControl.FindControl("txtAdjustedRate"), RadNumericTextBox).Text.ToString
 
                values("Approved") = CType(userControl.FindControl("cmbApproved"), RadComboBox).SelectedValue
 
                values("Billable") = CType(userControl.FindControl("cmbBillable"), RadComboBox).SelectedValue
 
                values("Rate") = CType(userControl.FindControl("txtRate"), RadNumericTextBox).Text
 
                values("LineRate") = CType(userControl.FindControl("txtLineRate"), RadTextBox).Text
            End If
 
            Dim db As New dbJobPricing
            Dim jp As New JobPricing
 
            jp.Worker = Convert.ToInt32(values("Worker").ToString)
            jp.JOBID = GetJobID(values("Job_OtherID").ToString)
            jp.WorkDate = DateTime.Parse(values("WorkDate").ToString)
            jp.WorkType = values("WorkType").ToString
            jp.Billable = values("Billable").ToString
            jp.Approved = values("Approved").ToString
            Try
                If Not values("StartedOn") Is Nothing Then
                    jp.StartedOn = DateTime.Parse(values("StartedOn").ToString)
                End If
            Catch ex As Exception
 
            End Try
 
            Try
                If Not values("EndedOn") Is Nothing Then
                    jp.EndedOn = DateTime.Parse(values("EndedOn").ToString)
                End If
            Catch ex As Exception
 
            End Try
 
 
            If values("ManualHRSdec") Is Nothing Or values("ManualHRSdec") = "" Then
                jp.ManualHRSdec = 0
            Else
                jp.ManualHRSdec = Convert.ToDouble(values("ManualHRSdec").ToString)
            End If
 
            If values("Units") Is Nothing Or values("Units") = "" Then
                jp.Units = 0
            Else
                jp.Units = Convert.ToDouble(values("Units").ToString)
            End If
 
 
            jp.BillType = Convert.ToInt32(values("BillType").ToString)
            If Not values("Comments") Is Nothing Then
                jp.Comments = values("Comments").ToString
            End If
 
            jp.Rate = Double.Parse(Replace(values("Rate"), "$", ""))
            jp.LineRate = Double.Parse(Replace(values("LineRate"), "$", ""))
            If values("AdjustedRate") <> "" Then
                jp.AdjustedRate = Double.Parse(Replace(values("AdjustedRate"), "$", ""))
            End If
 
            If "CrewDetails".Equals(e.Item.OwnerTableView.Name) Then
                Dim parentItem As GridDataItem = DirectCast(e.Item.OwnerTableView.ParentItem, GridDataItem)
                jp.MasterID = parentItem.OwnerTableView.DataKeyValues(parentItem.ItemIndex)("ID").ToString
            Else
 
                jp.MasterID = Nothing
            End If
 
            If jp.BillType = 0 Then
                If values("AdjustedRate") <> "" Then
                    jp.LineRate = jp.AdjustedRate * jp.HRSdec
                End If
            End If
            jp.BillingRateDesc = db.GetBillingDesc(jp)
            db.RegisterNew(jp)
            db.Commit()
            '  Me.Label1.Text &= "FIN"
        Catch ex As Exception
            Me.Label1.Text &= ex.Message & "<br>"
        End Try
 
 
 
    End Sub
 
    Protected Function GetJobID(JobOtherID As String) As String
        Dim db As New dbJob
        Dim j As JOB = db.GetByOtherID(JobOtherID)
        If Not j Is Nothing Then
            Return j.JOB_NBR
        Else
            Return ""
        End If
 
    End Function
 
    Protected Sub gvCrewMemberLabor1_UpdateCommand(sender As Object, e As GridCommandEventArgs) Handles gvCrewMemberLabor1.UpdateCommand
        Try
            Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)
            '  Me.Label1.Text &= "UpdateCommand Called"
            Dim values As New Hashtable()
 
            Dim userControl As UserControl = CType(e.Item.FindControl(GridEditFormItem.EditFormUserControlID), UserControl)
            If Not userControl Is Nothing Then
                values("ID") = item.GetDataKeyValue("ID")
 
                values("Worker") = CType(userControl.FindControl("cmbWorker"), RadComboBox).SelectedValue
                values("Job_OtherID") = CType(userControl.FindControl("txtJobNumber"), RadTextBox).Text
                values("WorkDate") = CType(userControl.FindControl("dtWorkDate"), RadDatePicker).SelectedDate
                values("WorkType") = CType(userControl.FindControl("txtWorkCode"), RadTextBox).Text
                values("StartedOn") = CType(userControl.FindControl("dtStartedAt"), RadTimePicker).SelectedDate
                values("EndedOn") = CType(userControl.FindControl("dtEndedAt"), RadTimePicker).SelectedDate
                values("ManualHRSdec") = CType(userControl.FindControl("txtHours"), RadNumericTextBox).Text
                values("Units") = CType(userControl.FindControl("txtUnits"), RadNumericTextBox).Text
                values("BillType") = CType(userControl.FindControl("cmbBillType"), RadComboBox).SelectedValue
                values("Comments") = CType(userControl.FindControl("txtComments"), RadTextBox).Text
                values("AdjustedRate") = CType(userControl.FindControl("txtAdjustedRate"), RadNumericTextBox).Text.ToString
                values("Approved") = CType(userControl.FindControl("cmbApproved"), RadComboBox).SelectedValue
                values("Billable") = CType(userControl.FindControl("cmbBillable"), RadComboBox).SelectedValue
                values("Rate") = CType(userControl.FindControl("txtRate"), RadNumericTextBox).Text
                values("LineRate") = CType(userControl.FindControl("txtLineRate"), RadTextBox).Text
 
            End If
 
            ' Throw New Exception(values("Rate"))
            Dim db As New dbJobPricing
            Dim jp As JobPricing = db.GetByID(values("ID").ToString)
 
            jp.Worker = Convert.ToInt32(values("Worker").ToString)
            jp.JOBID = GetJobID(values("Job_OtherID").ToString)
            jp.WorkDate = DateTime.Parse(values("WorkDate").ToString)
            jp.WorkType = values("WorkType").ToString
 
            Try
                If Not values("StartedOn") Is Nothing And values("StartedOn").ToString <> "" Then
                    jp.StartedOn = DateTime.Parse(values("StartedOn").ToString)
                End If
            Catch ex As Exception
 
            End Try
 
            Try
                If Not values("EndedOn") Is Nothing And values("EndedOn").ToString <> "" Then
                    jp.EndedOn = DateTime.Parse(values("EndedOn").ToString)
                End If
            Catch ex As Exception
 
            End Try
 
 
 
            If values("ManualHRSdec") Is Nothing Or values("ManualHRSdec") = "" Then
                jp.ManualHRSdec = 0
            Else
                jp.ManualHRSdec = Convert.ToDouble(values("ManualHRSdec").ToString)
            End If
 
            If values("Units") Is Nothing Or values("Units") = "" Then
                jp.Units = 0
            Else
                jp.Units = Convert.ToDouble(values("Units").ToString)
            End If
 
            'jp.MasterID = Convert.ToInt32(values("MasterID").ToString)
            jp.Rate = Double.Parse(Replace(values("Rate"), "$", ""))
            jp.LineRate = Double.Parse(Replace(values("LineRate"), "$", ""))
 
            If values("AdjustedRate") <> "" Then
                jp.AdjustedRate = Double.Parse(Replace(values("AdjustedRate"), "$", ""))
            End If
 
            jp.BillType = Convert.ToInt32(values("BillType").ToString)
            jp.Comments = values("Comments").ToString
            jp.Approved = Convert.ToInt32(values("Approved"))
            jp.Billable = Convert.ToInt32(values("Billable"))
            jp.BillingRateDesc = db.GetBillingDesc(jp)
            db.Commit()
 
        Catch ex As Exception
            Me.Label1.Text &= "<br>" & ex.Message & "<br>" & ex.StackTrace.ToString
        End Try
    End Sub
 
    Protected Sub btnApproveAll_Click(sender As Object, e As EventArgs) Handles btnApproveAll.Click
        ' Approval All
 
        ' Get List of Items in Current View
        Dim intCount As Integer = 0
        Me.gvCrewMemberLabor1.AllowPaging = False
        For Each row As GridDataItem In gvCrewMemberLabor1.Items
 
            Dim id As Long = row.GetDataKeyValue("ID")
 
            Dim db As New dbJobPricing
            Dim jp As JobPricing = db.GetByID(id)
            If Not jp Is Nothing And jp.Approved <> 1 Then
                jp.Approved = 1
                db.Commit()
                intCount += 1
            End If
 
        Next
        gvCrewMemberLabor1.Rebind()
 
        Me.gvCrewMemberLabor1.AllowPaging = True
        Me.Label1.Text &= intCount & " Entries Approved"
 
    End Sub
 
End Class


0
Daniel
Telerik team
answered on 23 Dec 2013, 03:02 PM
Hello Mark,

This code throws an exception because RadGrid will clear most controls when exporting and when ExportOnlyData is set to true. You can either use a flag to sidestep this code or disable "ExportOnlyData". The correct approach depends on your scenario and the desired output.

Regards,
Daniel
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
Grid
Asked by
Martin
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Martin
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Mark
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or