9 Answers, 1 is accepted
You can use the SelectedDateChanged event of the pickers to achieve this functionality:
protected void RadDatePicker1_SelectedDateChanged(object sender, Telerik.WebControls.SelectedDateChangedEventArgs e)
{
RadDatePicker2.MinDate = (sender as RadDatePicker).SelectedDate.Value.AddDays(2);
}
You can review this KB article for implementing the DatePicker in RadGrid template column.
Greetings,
Steve
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Thanks - I understand that and have got it working today to a point.
Surely you have to use and addhandler on during itemcreated / itemdatabound though as the control doesn't exist until runtime or am I missing something here?
Regards
Richard
That is correct. The other option is to attach the handler for control inside the grid template directly in the aspx of the page through the respective control's tag. Thus you will be able to handle its server-side events.
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Got that working using the following functionality.
<telerik:GridTemplateColumn HeaderText="Start Date" SortExpression="Start_Date" UniqueName="Start_Date"
EditFormColumnIndex="0">
<HeaderStyle Width="300px" />
<ItemTemplate>
<asp:Label runat="server" ID="lblStart_Date" Text='<%# Eval("Start_Date","{0:D}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadDatePicker ID="raddpStart_Date" runat="server" Culture="English (Australia)"
DbSelectedDate='<%# Bind("Start_Date", "{0:d}") %>' SharedCalendarID="" AutoPostBack="True" OnSelectedDateChanged="raddpStart_Date_SelectedDateChanged">
</telerik:RadDatePicker>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="End Date" SortExpression="End_Date" UniqueName="End_Date"
EditFormColumnIndex="0">
<HeaderStyle Width="300px" />
<ItemTemplate>
<asp:Label runat="server" ID="lblEnd_Date" Text='<%# Eval("End_Date","{0:D}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadDatePicker ID="raddpEnd_Date" runat="server" Culture="English (Australia)"
DbSelectedDate='<%# Bind("End_Date", "{0:d}") %>' SharedCalendarID="" MinDate ='<%# Bind("End_Date", "{0:d}") %>' AutoPostBack="True" OnSelectedDateChanged="raddpEnd_Date_SelectedDateChanged">
</telerik:RadDatePicker>
</EditItemTemplate>
</telerik:GridTemplateColumn>
The postback is calling the subroutines correctly but I cant get the MinDate to set correctly.
The function determine leave hours is correctly setting the value of the textbox but the MinDate is not getting changed.
Public Sub raddpStart_Date_SelectedDateChanged(ByVal sender As Object, ByVal e As System.EventArgs)
'first reference the edited grid item through the NamingContainer attribute
Dim editedItem As GridEditableItem = CType(CType(sender, RadDatePicker).NamingContainer, GridEditableItem)
' set the min date for the end date calendar to the value of the start date calendar
Dim raddpStart_Date As RadDatePicker = CType(editedItem("Start_Date").FindControl("raddpStart_Date"), RadDatePicker)
Dim raddpEnd_Date As RadDatePicker = CType(editedItem("End_Date").FindControl("raddpEnd_Date"), RadDatePicker)
Dim txtHours As TextBox = CType(editedItem("Hours").FindControl("txtHours"), TextBox)
If raddpEnd_Date.SelectedDate < raddpStart_Date.SelectedDate Then
raddpEnd_Date.MinDate = raddpStart_Date.SelectedDate
End If
txtHours.Text = Determine_Leave_Hours(raddpStart_Date.DbSelectedDate, raddpEnd_Date.DbSelectedDate)
End Sub
Any ideas?
Thanks
Richard
I tested your code and the MinDate of the second DatePicker is set as expected. You can see that in the attached sample. Let me know if I am leaving something from your logic out.
Best regards,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Yes, you logic looks the same.
I've discovered an interseting thing that occurs. On the second time that I change the Start Date I receive the following Error occurs on the page:
Error: Sys.InvalidOperationException: Two components with the same id 'radgrdEmployee_Leave_ctl00_ctl02_ctl02_raddpStart_Date_calendar' cant be added to the application.
I cant see why this is occuring. Perhaps this is related?
Thanks
Richard
Unfortunately I couldn't reproduce the error. Please investigate if there is possibility to have controls with duplicate IDs anywhere on your page. Or give us the rest of your code connected to the Grid or the DatePickers. More details about your page will help us to see where the issue comes from.
Regards,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

I've managed to now get it to set the MinDate correctly but the error is still occurring on the second postback for the raddpStart_Date_Leave control.
I've attached the code below:
ASPX:
<%
@ Page Language="VB" AutoEventWireup="false" CodeFile="RadEmployees.aspx.vb" Inherits="IMS.RadEmployees" MaintainScrollPositionOnPostback="true"%>
<%
@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>
<%
@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%
@ Register TagPrefix="ucPageHeader" Src="../User Controls/pageheader.ascx" TagName="PageHeader" %>
<%
@ Register TagPrefix="ucPageFooter" Src="../User Controls/pagefooter.ascx" TagName="PageFooter" %>
<!
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>IMS - Employees Maintenance</title>
<link href="../Styles.css" rel="stylesheet" type="text/css" />
</
head>
<
body>
<form id="frmEmployees" runat="server">
<ucPageHeader:PageHeader runat="server" ID="ucPageHeader" EnableViewState="true" Visible="true" />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager" runat="server"
DefaultLoadingPanelID="RadAjaxLoadingPanel">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="radgridEmployees">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="radgridEmployees"
LoadingPanelID="RadAjaxLoadingPanel" />
<telerik:AjaxUpdatedControl ControlID="radgridEmployee_Costs"
LoadingPanelID="RadAjaxLoadingPanel" />
<telerik:AjaxUpdatedControl ControlID="radgridEmployee_Leave"
LoadingPanelID="RadAjaxLoadingPanel" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="radgridEmployee_Costs">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="radgridEmployee_Costs"
LoadingPanelID="RadAjaxLoadingPanel" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="radgridEmployee_Leave">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="radgridEmployee_Leave"
LoadingPanelID="RadAjaxLoadingPanel" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel" runat="server"
Height="75px" Width="75px" Transparency="10" >
<img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' style="border:0;" />
</telerik:RadAjaxLoadingPanel>
<telerik:RadGrid ID="radgridEmployees" runat="server"
AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
AllowAutomaticUpdates="True" AllowPaging="True" AllowSorting="True"
DataSourceID="dsEmployees" GridLines="None" ShowFooter="True"
ShowStatusBar="True" AutoGenerateColumns="False"
Width="97%" PageSize="5">
<
ExportSettings OpenInNewWindow="True" IgnorePaging="True">
<
Pdf PaperSize="A4" FontType="Subset"></Pdf>
<
Excel Format="Html"></Excel>
</
ExportSettings>
<PagerStyle AlwaysVisible="True" Mode="Slider"/>
<
MasterTableView CurrentResetPageIndexAction="SetPageIndexToFirst" Dir="LTR" Frame="Border"
TableLayout="Auto" CommandItemDisplay="Bottom" AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="dsEmployees" Caption="Employee Maintenance">
<
RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Visible="False">
<
HeaderStyle Width="25px"></HeaderStyle>
</
RowIndicatorColumn>
<
ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Visible="False" Resizable="False">
<
HeaderStyle Width="25px"></HeaderStyle>
</
ExpandCollapseColumn>
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
<HeaderStyle Width="25px" VerticalAlign="Middle" HorizontalAlign="Center"/>
<ItemStyle CssClass="MyImageButton" Width="25px"/>
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn ConfirmText="Delete this Employee?" ButtonType="ImageButton"
CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
<HeaderStyle Width="25px" />
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" Width="25px" VerticalAlign="Middle"/>
</telerik:GridButtonColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="ID"
DataType="System.Int32" FilterListOptions="VaryByDataType"
ForceExtractValue="None" HeaderText="ID" ReadOnly="True" SortExpression="ID"
UniqueName="ID" >
<HeaderStyle Width="25px" />
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Name" SortExpression="Name" UniqueName="Name"
EditFormColumnIndex="0">
<HeaderStyle Width="80px" />
<ItemTemplate>
<asp:Label runat="server" ID="lblName" Text='<%# Eval("Name") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtName" Text='<%# Bind("Name") %>' Width="200px"></asp:TextBox>
<span style="color: Red">*</span>
<asp:RequiredFieldValidator ID="rfvName" ControlToValidate="txtName" ErrorMessage="This Field is Required." runat="server" SetFocusOnError="True" Display="Dynamic" Visible="True"></asp:RequiredFieldValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Logon ID" SortExpression="Logon_ID" UniqueName="Logon_ID"
EditFormColumnIndex="0">
<HeaderStyle Width="80px" />
<ItemTemplate>
<asp:Label runat="server" ID="lblLogon_ID" Text='<%# Eval("Logon_ID") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtLogon_ID" Text='<%# Bind("Logon_ID") %>' Width="200px"></asp:TextBox>
<span style="color: Red">*</span>
<asp:RequiredFieldValidator ID="rfvLogon_ID" ControlToValidate="txtLogon_ID" ErrorMessage="This Field is Required." runat="server" SetFocusOnError="True" Display="Dynamic" Visible="True"></asp:RequiredFieldValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter"
DataField="Phone_Home" FilterListOptions="VaryByDataType"
ForceExtractValue="None" HeaderText="Home Phone" SortExpression="Phone_Home"
UniqueName="Phone_Home" EditFormColumnIndex="0">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter"
DataField="Phone_Mobile" FilterListOptions="VaryByDataType"
ForceExtractValue="None" HeaderText="Mobile Phone"
SortExpression="Phone_Mobile" UniqueName="Phone_Mobile" EditFormColumnIndex="0">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Email Address" SortExpression="Email_Address" UniqueName="Email_Address"
EditFormColumnIndex="0">
<HeaderStyle Width="200px" />
<ItemTemplate>
<asp:Label runat="server" ID="lblEmail_Address" Text='<%# Eval("Email_Address") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtEmail_Address" Text='<%# Bind("Email_Address") %>' Width="200px"></asp:TextBox>
<span style="color: Red">*</span>
<asp:RequiredFieldValidator ID="rfvEmail_Address" ControlToValidate="txtEmail_Address" ErrorMessage="This Field is Required." runat="server" SetFocusOnError="True" Display="Dynamic" Visible="True"></asp:RequiredFieldValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridDropDownColumn DataField="Department_ID" DataSourceID="dsDepartments"
HeaderText="Department" ListTextField="Name" ListValueField="ID"
UniqueName="Department_ID" EditFormColumnIndex="0">
</telerik:GridDropDownColumn>
<telerik:GridDropDownColumn DataField="Access_Level_ID" DataSourceID="dsAccess_Levels"
HeaderText="Access Level" ListTextField="Name" ListValueField="ID"
UniqueName="Access_Level_ID" EditFormColumnIndex="0">
</telerik:GridDropDownColumn>
<telerik:GridTemplateColumn HeaderText="Commission Break Even Currency Value" SortExpression="Commission_Break_Even_Value" UniqueName="Commission_Break_Even_Value"
EditFormColumnIndex="1" Visible="false">
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtCommission_Break_Even_Value" Text='<%# Bind("Commission_Break_Even_Value") %>' Width="200px"></asp:TextBox>
<asp:CompareValidator ID="cvCommission_Break_Even_Value" runat="server" ErrorMessage="This Field Must be a Currency Value" SetFocusOnError="True" ControlToValidate="txtCommission_Break_Even_Value" Type="Currency" Operator="DataTypeCheck"></asp:CompareValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Commission Percentage" SortExpression="Commission_Percentage" UniqueName="Commission_Percentage"
EditFormColumnIndex="1" Visible="false">
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtCommission_Percentage" Text='<%# Bind("Commission_Percentage") %>' Width="200px"></asp:TextBox>
<asp:CompareValidator ID="cvCommission_Percentage" runat="server" ErrorMessage="This Field Must be a % Value" SetFocusOnError="True" ControlToValidate="txtCommission_Percentage" Type="Double" Operator="DataTypeCheck"></asp:CompareValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridCheckBoxColumn CurrentFilterFunction="NoFilter"
DataField="View_All_Employees_On_Commission_Reports" DataType="System.Boolean"
FilterListOptions="VaryByDataType" ForceExtractValue="None"
HeaderText="View All Employees On Commission Reports"
SortExpression="View_All_Employees_On_Commission_Reports"
UniqueName="View_All_Employees_On_Commission_Reports" Visible="false" EditFormColumnIndex="1">
</telerik:GridCheckBoxColumn>
<telerik:GridCheckBoxColumn CurrentFilterFunction="NoFilter"
DataField="Self_Allocate_Client_Tasks" DataType="System.Boolean"
FilterListOptions="VaryByDataType" ForceExtractValue="None"
HeaderText="Able to Self Allocate Client Tasks"
SortExpression="Self_Allocate_Client_Tasks"
UniqueName="Self_Allocate_Client_Tasks" Visible="false" EditFormColumnIndex="1">
</telerik:GridCheckBoxColumn>
<telerik:GridDropDownColumn DataField="State_ID" DataSourceID="dsStates"
HeaderText="State" ListTextField="Name" ListValueField="ID"
UniqueName="State_ID" EditFormColumnIndex="0">
</telerik:GridDropDownColumn>
<telerik:GridCheckBoxColumn CurrentFilterFunction="NoFilter"
DataField="Terminated" DataType="System.Boolean"
FilterListOptions="VaryByDataType" ForceExtractValue="None"
HeaderText="Terminated" SortExpression="Terminated" UniqueName="Terminated" Visible="false" EditFormColumnIndex="0">
</telerik:GridCheckBoxColumn>
<telerik:GridDropDownColumn DataField="Timesheets_Access_Permissions_ID" DataSourceID="dsTimesheet_Access_Permissions"
HeaderText="Timesheet Access Permissions" ListTextField="Description" ListValueField="ID"
UniqueName="Timesheet_Access_Permissions" EditFormColumnIndex="1">
</telerik:GridDropDownColumn>
</Columns>
<EditFormSettings ColumnNumber="2" CaptionDataField="Name" CaptionFormatString="You Are Currently Editing Employee Name: {0}">
<FormTableItemStyle Wrap="False"></FormTableItemStyle>
<FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
<FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
Width="100%" />
<FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
<EditColumn ButtonType="ImageButton"
UpdateImageUrl="~/Images/save.gif" EditImageUrl="~/Images/edit.gif" InsertImageUrl="~/Images/save.gif" CancelImageUrl="~/Images/cancel.gif"
InsertText="Insert Employee" UpdateText="Update Employee" UniqueName="EditCommandColumnEmployees" CancelText="Cancel Edit">
</EditColumn>
<FormTableButtonRowStyle HorizontalAlign="Center" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
<FormTableStyle CellSpacing="0" CellPadding="2" CssClass="module" Height="110px"
BackColor="White" />
</EditFormSettings>
</
MasterTableView>
<ClientSettings AllowKeyboardNavigation="true" ApplyStylesOnClient="true" EnablePostBackOnRowClick="true">
<Selecting AllowRowSelect="true"/>
</ClientSettings>
</telerik:RadGrid>
<br />
<br />
<telerik:RadGrid ID="radgridEmployee_Costs" runat="server"
AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
AllowAutomaticUpdates="True" AllowPaging="True" AllowSorting="True"
DataSourceID="dsEmployee_Costs" GridLines="None" ShowFooter="True"
ShowStatusBar="True" AutoGenerateColumns="False"
Width="97%" PageSize="5">
<
ExportSettings OpenInNewWindow="True" IgnorePaging="True">
<
Pdf PaperSize="A4" FontType="Subset"></Pdf>
<
Excel Format="Html"></Excel>
<
Csv RowDelimiter="NewLine" ColumnDelimiter="Comma"></Csv>
</
ExportSettings>
<PagerStyle AlwaysVisible="True" Mode="Slider" />
<
MasterTableView CurrentResetPageIndexAction="SetPageIndexToFirst" Dir="LTR" Frame="Border"
TableLayout="Auto" CommandItemDisplay="Bottom" AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="dsEmployee_Costs" Caption="Employee Costs Maintenance - Rows Highlighted in Yellow Are Previous Costs and Can Not be Deleted">
<
RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Visible="False">
<
HeaderStyle Width="25px"></HeaderStyle>
</
RowIndicatorColumn>
<
ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Visible="False" Resizable="False">
<
HeaderStyle Width="25px"></HeaderStyle>
</
ExpandCollapseColumn>
<Columns>
<telerik:GridButtonColumn ConfirmText="Delete this Employee Cost?" ButtonType="ImageButton"
CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
<HeaderStyle Width="25px" />
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" Width="25px" VerticalAlign="Middle" />
</telerik:GridButtonColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="ID"
DataType="System.Int32" FilterListOptions="VaryByDataType"
ForceExtractValue="None" HeaderText="ID" ReadOnly="True" SortExpression="ID"
UniqueName="ID" >
<HeaderStyle Width="25px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Employee_ID"
FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Employee_ID"
SortExpression="Employee_ID" UniqueName="Employee_ID"
EditFormColumnIndex="0" DataType="System.Int32" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Start Date" SortExpression="Start_Date" UniqueName="Start_Date"
EditFormColumnIndex="0" >
<HeaderStyle Width="300px" />
<ItemTemplate>
<asp:Label runat="server" ID="lblStart_Date" Text='<%# Eval("Start_Date","{0:D}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadDatePicker ID="raddpStart_Date" runat="server" Culture="English (Australia)"
DbSelectedDate='<%# Bind("Start_Date") %>' SharedCalendarID="">
</telerik:RadDatePicker>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Cost Per Hour" SortExpression="Cost_Per_Hour" UniqueName="Cost_Per_Hour"
EditFormColumnIndex="0">
<ItemTemplate>
<asp:Label runat="server" ID="lblCost_Per_Hour" Text='<%# Eval("Cost_Per_Hour","{0:C}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtCost_Per_Hour" Text='<%# Bind("Cost_Per_Hour") %>' ></asp:TextBox>
<span style="color: Red">*</span>
<asp:RequiredFieldValidator ID="rfvCost_Per_Hour" ControlToValidate="txtCost_Per_Hour" ErrorMessage="This Field is Required." runat="server" SetFocusOnError="True" Display="Dynamic" Visible="True"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvCost_Per_Hour" runat="server" ErrorMessage="This Field Must be a Currency Value" SetFocusOnError="True" ControlToValidate="txtCost_Per_Hour" Type="Currency" Operator="DataTypeCheck"></asp:CompareValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Cost Per Hour OT" SortExpression="Cost_Per_Hour_OT" UniqueName="Cost_Per_Hour_OT"
EditFormColumnIndex="0">
<ItemTemplate>
<asp:Label runat="server" ID="lblCost_Per_Hour_OT" Text='<%# Eval("Cost_Per_Hour_OT","{0:C}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtCost_Per_Hour_OT" Text='<%# Bind("Cost_Per_Hour_OT") %>' ></asp:TextBox>
<span style="color: Red">*</span>
<asp:RequiredFieldValidator ID="rfvCost_Per_Hour_OT" ControlToValidate="txtCost_Per_Hour_OT" ErrorMessage="This Field is Required." runat="server" SetFocusOnError="True" Display="Dynamic" Visible="True"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvCost_Per_Hour_OT" runat="server" ErrorMessage="This Field Must be a Currency Value" SetFocusOnError="True" ControlToValidate="txtCost_Per_Hour_OT" Type="Currency" Operator="DataTypeCheck"></asp:CompareValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Normal Hours Per Week" SortExpression="Normal_Hours_Per_Week" UniqueName="Normal_Hours_Per_Week"
EditFormColumnIndex="0">
<ItemTemplate>
<asp:Label runat="server" ID="lblNormal_Hours_Per_Week" Text='<%# Eval("Normal_Hours_Per_Week") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtNormal_Hours_Per_Week" Text='<%# Bind("Normal_Hours_Per_Week") %>' ></asp:TextBox>
<span style="color: Red">*</span>
<asp:RequiredFieldValidator ID="rfvNormal_Hours_Per_Week" ControlToValidate="txtNormal_Hours_Per_Week" ErrorMessage="This Field is Required." runat="server" SetFocusOnError="True" Display="Dynamic" Visible="True"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvNormal_Hours_Per_Week" runat="server" ErrorMessage="This Field Must be a Decimal Value" SetFocusOnError="True" ControlToValidate="txtNormal_Hours_Per_Week" Type="Double" Operator="DataTypeCheck"></asp:CompareValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<EditFormSettings ColumnNumber="1">
<FormTableItemStyle Wrap="False"></FormTableItemStyle>
<FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
<FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
Width="100%" />
<FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
<EditColumn ButtonType="ImageButton"
UpdateImageUrl="~/Images/save.gif" EditImageUrl="~/Images/edit.gif" InsertImageUrl="~/Images/save.gif" CancelImageUrl="~/Images/cancel.gif"
InsertText="Insert Employee Cost" UpdateText="Update Employee Cost" UniqueName="EditCommandColumnEmployee_Costs" CancelText="Cancel Edit">
</EditColumn>
<FormTableButtonRowStyle HorizontalAlign="Center" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
<FormTableStyle CellSpacing="0" CellPadding="2" CssClass="module" Height="110px"
BackColor="White" />
</EditFormSettings>
</
MasterTableView>
<ClientSettings AllowKeyboardNavigation="true" ApplyStylesOnClient="true" EnablePostBackOnRowClick="false">
</ClientSettings>
</telerik:RadGrid>
<br />
<br />
<telerik:RadGrid ID="radgridEmployee_Leave" runat="server"
AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
AllowAutomaticUpdates="True" AllowPaging="True" AllowSorting="True"
DataSourceID="dsEmployee_Leave" GridLines="None" ShowFooter="True"
ShowStatusBar="True" AutoGenerateColumns="False"
Width="97%" PageSize="5">
<
ExportSettings OpenInNewWindow="True" IgnorePaging="True">
<
Pdf PaperSize="A4" FontType="Subset"></Pdf>
<
Excel Format="Html"></Excel>
<
Csv RowDelimiter="NewLine" ColumnDelimiter="Comma"></Csv>
</
ExportSettings>
<PagerStyle AlwaysVisible="True" Mode="Slider" />
<
MasterTableView CurrentResetPageIndexAction="SetPageIndexToFirst" Dir="LTR" Frame="Border"
TableLayout="Auto" CommandItemDisplay="Bottom" AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="dsEmployee_Leave" Caption="Employee Leave Maintenance - Rows Highlighted in Yellow Have Been Authorised or Rejected and Can Only be Deleted">
<
RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Visible="False">
<
HeaderStyle Width="25px"></HeaderStyle>
</
RowIndicatorColumn>
<
ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Visible="False" Resizable="False">
<
HeaderStyle Width="25px"></HeaderStyle>
</
ExpandCollapseColumn>
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
<HeaderStyle Width="25px" VerticalAlign="Middle" HorizontalAlign="Center"/>
<ItemStyle CssClass="MyImageButton" Width="25px"/>
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn ConfirmText="Delete this Employee Leave Request?" ButtonType="ImageButton"
CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
<HeaderStyle Width="25px" />
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" Width="25px" VerticalAlign="Middle"/>
</telerik:GridButtonColumn>
<telerik:GridButtonColumn ConfirmText="Authorise this Employee Leave Request?" ButtonType="ImageButton"
CommandName="Authorise" Text="Authorise" UniqueName="Authorise" ImageUrl="~/Images/update.gif">
<HeaderStyle Width="25px" />
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" Width="25px" VerticalAlign="Middle"/>
</telerik:GridButtonColumn>
<telerik:GridButtonColumn ConfirmText="Reject this Employee Leave Request?" ButtonType="ImageButton"
CommandName="Reject" Text="Reject" UniqueName="Reject" ImageUrl="~/Images/reject.gif">
<HeaderStyle Width="25px" />
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" Width="25px" VerticalAlign="Middle"/>
</telerik:GridButtonColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="ID"
DataType="System.Int32" FilterListOptions="VaryByDataType"
ForceExtractValue="None" HeaderText="ID" ReadOnly="True" SortExpression="ID"
UniqueName="ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Employee_ID"
FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Employee_ID"
SortExpression="Employee_ID" UniqueName="Employee_ID"
EditFormColumnIndex="0" DataType="System.Int32" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridDropDownColumn DataField="Leave_Type_ID" DataSourceID="dsLeave_Types"
HeaderText="Leave Type" ListTextField="Name" ListValueField="ID"
UniqueName="Leave_Type">
</telerik:GridDropDownColumn>
<telerik:GridTemplateColumn HeaderText="Start Date" SortExpression="Start_Date" UniqueName="Start_Date_Leave"
EditFormColumnIndex="0">
<HeaderStyle Width="300px" />
<ItemTemplate>
<asp:Label runat="server" ID="lblStart_Date_Leave" Text='<%# Eval("Start_Date","{0:D}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadDatePicker ID="raddpStart_Date_Leave" runat="server" Culture="English (Australia)"
DbSelectedDate='<%# Bind("Start_Date") %>' SharedCalendarID="" AutoPostBack="True" OnSelectedDateChanged="raddpStart_Date_Leave_SelectedDateChanged">
</telerik:RadDatePicker>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="End Date" SortExpression="End_Date" UniqueName="End_Date_Leave"
EditFormColumnIndex="0">
<HeaderStyle Width="300px" />
<ItemTemplate>
<asp:Label runat="server" ID="lblEnd_Date_Leave" Text='<%# Eval("End_Date","{0:D}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadDatePicker ID="raddpEnd_Date_Leave" runat="server" Culture="English (Australia)"
DbSelectedDate='<%# Bind("End_Date") %>' MinDate ='<%# Bind("End_Date") %>' SharedCalendarID="" AutoPostBack="True" OnSelectedDateChanged="raddpEnd_Date_Leave_SelectedDateChanged">
</telerik:RadDatePicker>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Leave Hours" SortExpression="Hours" UniqueName="Hours"
EditFormColumnIndex="0">
<ItemTemplate>
<asp:Label runat="server" ID="lblHours" Text='<%# Eval("Hours","{0:C}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtHours" Text='<%# Bind("Hours") %>' ></asp:TextBox>
<span style="color: Red">*</span>
<asp:RequiredFieldValidator ID="rfvCost_Per_Hour" ControlToValidate="txtHours" ErrorMessage="This Field is Required." runat="server" SetFocusOnError="True" Display="Dynamic" Visible="True"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvHours" runat="server" ErrorMessage="This Field Must be a Decimal Value" SetFocusOnError="True" ControlToValidate="txtHours" Type="Double" Operator="DataTypeCheck"></asp:CompareValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Special Instructions" SortExpression="Special_Instructions" UniqueName="Special_Instructions"
EditFormColumnIndex="1">
<ItemTemplate>
<asp:Label runat="server" ID="lblSpecial_Instructions" Text='<%# Eval("Special_Instructions") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtSpecial_Instructions" Width="300px" Height="100px" TextMode="MultiLine" Text='<%# Bind("Special_Instructions") %>' ></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<EditFormSettings ColumnNumber="2" CaptionDataField="ID" CaptionFormatString="You Are Currently Editing Employee Leave Row ID: {0}">
<FormTableItemStyle Wrap="False"></FormTableItemStyle>
<FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
<FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
Width="100%" />
<FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
<EditColumn ButtonType="ImageButton"
UpdateImageUrl="~/Images/save.gif" EditImageUrl="~/Images/edit.gif" InsertImageUrl="~/Images/save.gif" CancelImageUrl="~/Images/cancel.gif"
InsertText="Insert Employee Leave" UpdateText="Update Employee Leave" UniqueName="EditCommandColumnEmployee_Leave" CancelText="Cancel Edit">
</EditColumn>
<FormTableButtonRowStyle HorizontalAlign="Center" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
<FormTableStyle CellSpacing="0" CellPadding="2" CssClass="module" Height="110px"
BackColor="White" />
</EditFormSettings>
</
MasterTableView>
<ClientSettings AllowKeyboardNavigation="true" ApplyStylesOnClient="true" EnablePostBackOnRowClick="false">
</ClientSettings>
</telerik:RadGrid>
<asp:SqlDataSource ID="dsEmployee_Leave" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:IMS_Production %>"
DeleteCommand="DELETE FROM [Employee_Leave] WHERE [ID] = @original_ID"
InsertCommand="INSERT INTO [Employee_Leave] ([Employee_ID], [Leave_Type_ID], [Start_Date], [End_Date], [Hours], [Special_Instructions]) VALUES (@Employee_ID, @Leave_Type_ID, @Start_Date, @End_Date, @Hours, @Special_Instructions)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Employee_Leave] WHERE ([Employee_ID] = @Employee_ID) ORDER BY [Start_Date] DESC"
UpdateCommand="UPDATE [Employee_Leave] SET [Employee_ID] = @Employee_ID, [Leave_Type_ID] = @Leave_Type_ID, [Start_Date] = @Start_Date, [End_Date] = @End_Date, [Hours] = @Hours, [Special_Instructions] = @Special_Instructions WHERE [ID] = @original_ID AND [Employee_ID] = @original_Employee_ID AND [Leave_Type_ID] = @original_Leave_Type_ID AND [Start_Date] = @original_Start_Date AND [End_Date] = @original_End_Date AND [Hours] = @original_Hours AND [Special_Instructions] = @original_Special_Instructions">
<SelectParameters>
<asp:ControlParameter ControlID="radgridEmployees" Name="Employee_ID"
PropertyName="SelectedValue" Type="Int32" />
<asp:Parameter DefaultValue="False" Name="Authorised" Type="Boolean" />
<asp:Parameter DefaultValue="False" Name="Rejected" Type="Boolean" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="original_ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Employee_ID" Type="Int32" />
<asp:Parameter Name="Leave_Type_ID" Type="Int32" />
<asp:Parameter Name="Start_Date" Type="DateTime" />
<asp:Parameter Name="End_Date" Type="DateTime" />
<asp:Parameter Name="Hours" Type="Decimal" />
<asp:Parameter Name="Special_Instructions" Type="String" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_Employee_ID" Type="Int32" />
<asp:Parameter Name="original_Leave_Type_ID" Type="Int32" />
<asp:Parameter Name="original_Start_Date" Type="DateTime" />
<asp:Parameter Name="original_End_Date" Type="DateTime" />
<asp:Parameter Name="original_Hours" Type="Decimal" />
<asp:Parameter Name="original_Special_Instructions" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Employee_ID" Type="Int32" />
<asp:Parameter Name="Leave_Type_ID" Type="Int32" />
<asp:Parameter Name="Start_Date" Type="DateTime" />
<asp:Parameter Name="End_Date" Type="DateTime" />
<asp:Parameter Name="Hours" Type="Decimal" />
<asp:Parameter Name="Special_Instructions" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsEmployees" runat="server"
ConnectionString="<%$ ConnectionStrings:IMS_Production %>"
DeleteCommand="DELETE FROM [Employees] WHERE [ID] = @ID"
InsertCommand="INSERT INTO [Employees] ([Name], [Logon_ID], [Phone_Home], [Phone_Mobile], [Department_ID], [Access_Level_ID], [Commission_Break_Even_Value], [Commission_Percentage], [Email_Address], [View_All_Employees_On_Commission_Reports], [Self_Allocate_Client_Tasks], [State_ID], [Timesheets_Access_Permissions_ID]) VALUES (@Name, @Logon_ID, @Phone_Home, @Phone_Mobile, @Department_ID, @Access_Level_ID, @Commission_Break_Even_Value, @Commission_Percentage, @Email_Address, @View_All_Employees_On_Commission_Reports, @Self_Allocate_Client_Tasks, @State_ID, @Timesheets_Access_Permissions_ID)"
SelectCommand="SELECT * FROM [Employees] WHERE ([Terminated] = @Terminated) ORDER BY [Name]"
UpdateCommand="UPDATE [Employees] SET [Name] = @Name, [Logon_ID] = @Logon_ID, [Phone_Home] = @Phone_Home, [Phone_Mobile] = @Phone_Mobile, [Department_ID] = @Department_ID, [Access_Level_ID] = @Access_Level_ID, [Terminated] = @Terminated, [Commission_Break_Even_Value] = @Commission_Break_Even_Value, [Commission_Percentage] = @Commission_Percentage, [Email_Address] = @Email_Address, [View_All_Employees_On_Commission_Reports] = @View_All_Employees_On_Commission_Reports, [Self_Allocate_Client_Tasks] = @Self_Allocate_Client_Tasks, [State_ID] = @State_ID, [Timesheets_Access_Permissions_ID] = @Timesheets_Access_Permissions_ID WHERE [ID] = @ID" >
<SelectParameters>
<asp:Parameter DefaultValue="False" Name="Terminated" Type="Boolean" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Logon_ID" Type="String" />
<asp:Parameter Name="Phone_Home" Type="String" />
<asp:Parameter Name="Phone_Mobile" Type="String" />
<asp:Parameter Name="Department_ID" Type="Int32" />
<asp:Parameter Name="Access_Level_ID" Type="Int32" />
<asp:Parameter Name="Terminated" Type="Boolean" />
<asp:Parameter Name="Commission_Break_Even_Value" Type="Decimal" />
<asp:Parameter Name="Commission_Percentage" Type="Decimal" />
<asp:Parameter Name="Email_Address" Type="String" />
<asp:Parameter Name="View_All_Employees_On_Commission_Reports" Type="Boolean" />
<asp:Parameter Name="Self_Allocate_Client_Tasks" Type="Boolean" />
<asp:Parameter Name="State_ID" Type="Int32" />
<asp:Parameter Name="Timesheets_Access_Permissions_ID" Type="Int32" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Logon_ID" Type="String" />
<asp:Parameter Name="Phone_Home" Type="String" />
<asp:Parameter Name="Phone_Mobile" Type="String" />
<asp:Parameter Name="Department_ID" Type="Int32" />
<asp:Parameter Name="Access_Level_ID" Type="Int32" />
<asp:Parameter Name="Commission_Break_Even_Value" Type="Decimal" />
<asp:Parameter Name="Commission_Percentage" Type="Decimal" />
<asp:Parameter Name="Email_Address" Type="String" />
<asp:Parameter Name="View_All_Employees_On_Commission_Reports" Type="Boolean" />
<asp:Parameter Name="Self_Allocate_Client_Tasks" Type="Boolean" />
<asp:Parameter Name="State_ID" Type="Int32" />
<asp:Parameter Name="Timesheets_Access_Permissions_ID" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsEmployee_Costs" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:IMS_Production %>"
DeleteCommand="DELETE FROM [Employee_Costs] WHERE [ID] = @original_ID"
InsertCommand="INSERT INTO [Employee_Costs] ([Employee_ID], [Start_Date], [End_Date], [Cost_Per_Hour], [Cost_Per_Hour_OT], [Normal_Hours_Per_Week]) VALUES (@Employee_ID, @Start_Date, @End_Date, @Cost_Per_Hour, @Cost_Per_Hour_OT, @Normal_Hours_Per_Week)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Employee_Costs] WHERE ([Employee_ID] = @Employee_ID) ORDER BY [Start_Date] DESC"
UpdateCommand="UPDATE [Employee_Costs] SET [Employee_ID] = @Employee_ID, [Start_Date] = @Start_Date, [End_Date] = @End_Date, [Cost_Per_Hour] = @Cost_Per_Hour, [Cost_Per_Hour_OT] = @Cost_Per_Hour_OT, [Normal_Hours_Per_Week] = @Normal_Hours_Per_Week WHERE [ID] = @original_ID AND [Employee_ID] = @original_Employee_ID AND [Start_Date] = @original_Start_Date AND [End_Date] = @original_End_Date AND [Cost_Per_Hour] = @original_Cost_Per_Hour AND [Cost_Per_Hour_OT] = @original_Cost_Per_Hour_OT AND [Normal_Hours_Per_Week] = @original_Normal_Hours_Per_Week">
<SelectParameters>
<asp:ControlParameter ControlID="radgridEmployees" Name="Employee_ID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="original_ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Employee_ID" Type="Int32" />
<asp:Parameter Name="Start_Date" Type="DateTime" />
<asp:Parameter Name="End_Date" Type="DateTime" />
<asp:Parameter Name="Cost_Per_Hour" Type="Decimal" />
<asp:Parameter Name="Cost_Per_Hour_OT" Type="Decimal" />
<asp:Parameter Name="Normal_Hours_Per_Week" Type="Byte" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_Employee_ID" Type="Int32" />
<asp:Parameter Name="original_Start_Date" Type="DateTime" />
<asp:Parameter Name="original_End_Date" Type="DateTime" />
<asp:Parameter Name="original_Cost_Per_Hour" Type="Decimal" />
<asp:Parameter Name="original_Cost_Per_Hour_OT" Type="Decimal" />
<asp:Parameter Name="original_Normal_Hours_Per_Week" Type="Byte" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Employee_ID" Type="Int32" />
<asp:Parameter Name="Start_Date" Type="DateTime" />
<asp:Parameter Name="End_Date" Type="DateTime" />
<asp:Parameter Name="Cost_Per_Hour" Type="Decimal" />
<asp:Parameter Name="Cost_Per_Hour_OT" Type="Decimal" />
<asp:Parameter Name="Normal_Hours_Per_Week" Type="Byte" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsDepartments" runat="server"
ConnectionString="<%$ ConnectionStrings:IMS_Production %>"
SelectCommand="SELECT [ID], [Name] FROM [Departments] ORDER BY [Name]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsAccess_Levels" runat="server"
ConnectionString="<%$ ConnectionStrings:IMS_Production %>"
SelectCommand="SELECT [ID], [Name] FROM [Access_Levels] ORDER BY [Name]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsStates" runat="server"
ConnectionString="<%$ ConnectionStrings:IMS_Production %>"
SelectCommand="SELECT [ID], [Name] FROM [States] ORDER BY [Name]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsTimesheet_Access_Permissions" runat="server"
ConnectionString="<%$ ConnectionStrings:IMS_Production %>"
SelectCommand="SELECT [ID], [Description] FROM [Timesheet_Access_Permissions] ORDER BY [ID]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsLeave_Types" runat="server"
ConnectionString="<%$ ConnectionStrings:IMS_Production %>"
SelectCommand="SELECT [ID], [Name] FROM [Leave_Types] ORDER BY [Name]">
</asp:SqlDataSource>
<ucPageFooter:PageFooter runat="server" ID="PageFooter" EnableViewState="true" Visible="true" />
</form>
</
body>
</
html>
Code Behind:
Imports
Telerik.Web.UI
Imports
System.Data.SqlClient
Imports
System.Web.Configuration
Namespace
IMS
Partial Class RadEmployees
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
' only do this when the page is loaded
If Not IsPostBack Then
' set the value of the pageheader
' set the value of the pageheader
Dim lblPageHeader As Label = Me.ucPageHeader.FindControl("lblPageHeader")
lblPageHeader.Text =
"Employees Maintenance"
' see if the user has permissions for this page
If Not Check_Form_Permissions("Maintain Employees", Me) Then
Response.Redirect(
"PermissionDenied.aspx", False)
End If
End If
' set connection sring for development if required
Set_Development_Connection_String(
Me)
' apply the skin to any radcontrols
Apply_RadControl_Skins(
Me)
' catch any errors
Catch err As Exception
' handle the errors
Control_Form_Errors(err,
Me)
End Try
End Sub
' if editing a row and then the user clicks on add close the edit window or
' if the user is adding a row and clicks on edit then close the add window
Protected Sub radgridEmployees_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles radgridEmployees.ItemCommand
Dim grid As RadGrid = CType(source, RadGrid)
If (e.CommandName = RadGrid.InitInsertCommandName) Then
grid.MasterTableView.ClearEditItems()
End If
If (e.CommandName = RadGrid.EditCommandName) Then
e.Item.OwnerTableView.IsItemInserted =
False
End If
End Sub
' if editing a row and then the user clicks on add close the edit window or
' if the user is adding a row and clicks on edit then close the add window
Protected Sub radgridEmployee_Costs_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles radgridEmployee_Costs.ItemCommand
If e.CommandName = RadGrid.InitInsertCommandName Then
e.Canceled =
True
Dim newValues As Hashtable = New Hashtable
newValues(
"Start_Date") = System.DateTime.Now()
newValues(
"Employee_ID") = Me.radgridEmployees.SelectedValue
e.Item.OwnerTableView.InsertItem(newValues)
End If
Dim grid As RadGrid = CType(source, RadGrid)
If (e.CommandName = RadGrid.InitInsertCommandName) Then
grid.MasterTableView.ClearEditItems()
End If
If (e.CommandName = RadGrid.EditCommandName) Then
e.Item.OwnerTableView.IsItemInserted =
False
End If
End Sub
' if editing a row and then the user clicks on add close the edit window or
' if the user is adding a row and clicks on edit then close the add window
Protected Sub radgridEmployee_Leave_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles radgridEmployee_Leave.ItemCommand
If e.CommandName = RadGrid.InitInsertCommandName Then
e.Canceled =
True
Dim newValues As Hashtable = New Hashtable
newValues(
"Start_Date") = System.DateTime.Now()
newValues(
"End_Date") = System.DateTime.Now()
newValues(
"Employee_ID") = Me.radgridEmployees.SelectedValue
newValues(
"Hours") = 8
e.Item.OwnerTableView.InsertItem(newValues)
End If
Dim grid As RadGrid = CType(source, RadGrid)
If (e.CommandName = RadGrid.InitInsertCommandName) Then
grid.MasterTableView.ClearEditItems()
End If
If (e.CommandName = RadGrid.EditCommandName) Then
e.Item.OwnerTableView.IsItemInserted =
False
End If
' authorise the leave
If e.CommandName = "Authorise" Then
IMS.Initialise_Database_Objects()
'update the row to reflect the status
cm.CommandText =
"UPDATE Employe_Leave SET Authorised = 1, Rejected = 0, Date_Authorised_Rejected = GETDATE(), Authorised_Rejected_By_Employee_ID = " & Session("Employee_ID") & " WHERE ID = " & Me.radgridEmployee_Leave.SelectedValue
cm.ExecuteNonQuery()
'send an email to the employee
IMS.Create_Employee_Leave_Request_Authorised_or_Rejected_Email(
Me.radgridEmployee_Leave.SelectedValue, True, Me, Nothing)
Display_Ajax_Messagebox(
"An email has been sent to the Employee notifying them that the Leave Request has been Approved", RadAjaxManager)
End If
' reject the leave
If e.CommandName = "Rejected" Then
IMS.Initialise_Database_Objects()
'update the row to reflect the status
cm.CommandText =
"UPDATE Employee_Leave SET Authorised = 0, Rejected = 1, Date_Authorised_Rejected = GETDATE(), Authorised_Rejected_By_Employee_ID = " & Session("Employee_ID") & " WHERE ID = " & Me.radgridEmployee_Leave.SelectedValue
cm.ExecuteNonQuery()
'send an email to the employee
IMS.Create_Employee_Leave_Request_Authorised_or_Rejected_Email(
Me.radgridEmployee_Leave.SelectedValue, False, Me, Nothing)
Display_Ajax_Messagebox(
"An email has been sent to the Employee notifying them that the Leave Request has been Rejected", RadAjaxManager)
End If
End Sub
' display notification that an item has been updated or if an update cant take place
Protected Sub radgridEmployees_ItemUpdated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridUpdatedEventArgs) Handles radgridEmployees.ItemUpdated
Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
Dim id As String = item.GetDataKeyValue("ID").ToString()
If Not e.Exception Is Nothing Then
e.KeepInEditMode =
True
e.ExceptionHandled =
True
Display_Ajax_Messagebox(
"Employee " + id + " cannot be deleted. Reason: " + e.Exception.Message, Me.RadAjaxManager)
Else
radgridEmployees.Controls.Add(
New LiteralControl(String.Format("<span style='color:red'>{0}</span>", "Employee: " + id + " Updated.")))
End If
End Sub
' display notification that an item has been updated or if an update cant take place
Protected Sub radgridEmployee_Costs_ItemUpdated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridUpdatedEventArgs) Handles radgridEmployee_Costs.ItemUpdated
Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
Dim id As String = item.GetDataKeyValue("ID").ToString()
If Not e.Exception Is Nothing Then
e.KeepInEditMode =
True
e.ExceptionHandled =
True
Display_Ajax_Messagebox(
"Employee Cost " + id + " cannot be updated. Reason: " + e.Exception.Message, Me.RadAjaxManager)
Else
radgridEmployee_Costs.Controls.Add(
New LiteralControl(String.Format("<span style='color:red'>{0}</span>", "Employee Cost: " + id + " Updated.")))
End If
End Sub
' display notification that an item has been updated or if an update cant take place
Protected Sub radgridEmployee_Leave_ItemUpdated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridUpdatedEventArgs) Handles radgridEmployee_Leave.ItemUpdated
Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
Dim id As String = item.GetDataKeyValue("ID").ToString()
If Not e.Exception Is Nothing Then
e.KeepInEditMode =
True
e.ExceptionHandled =
True
Display_Ajax_Messagebox(
"Employee " + id + " cannot be deleted. Reason: " + e.Exception.Message, Me.RadAjaxManager)
Else
radgridEmployee_Leave.Controls.Add(
New LiteralControl(String.Format("<span style='color:red'>{0}</span>", "Employee Leave: " + id + " Updated.")))
End If
End Sub
' display notification that an item has been inserted or the insert cant take place
Protected Sub radgridEmployees_ItemInserted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridInsertedEventArgs) Handles radgridEmployees.ItemInserted
If Not e.Exception Is Nothing Then
e.ExceptionHandled =
True
e.KeepInInsertMode =
True
Display_Ajax_Messagebox(
"Employee cannot be inserted. Reason: " + e.Exception.Message, Me.RadAjaxManager)
Else
radgridEmployees.Controls.Add(
New LiteralControl(String.Format("<span style='color:red'>{0}</span>", "New Employee Row Inserted.")))
End If
End Sub
' display notification that an item has been inserted or the insert cant take place
Protected Sub radgridEmployee_Costs_ItemInserted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridInsertedEventArgs) Handles radgridEmployee_Costs.ItemInserted
If Not e.Exception Is Nothing Then
e.ExceptionHandled =
True
e.KeepInInsertMode =
True
Display_Ajax_Messagebox(
"Employee Cost cannot be inserted. Reason: " + e.Exception.Message, Me.RadAjaxManager)
Else
radgridEmployee_Costs.Controls.Add(
New LiteralControl(String.Format("<span style='color:red'>{0}</span>", "New Employee Cost Row Inserted.")))
End If
End Sub
' display notification that an item has been inserted or the insert cant take place
Protected Sub radgridEmployee_Leave_ItemInserted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridInsertedEventArgs) Handles radgridEmployee_Leave.ItemInserted
If Not e.Exception Is Nothing Then
e.ExceptionHandled =
True
e.KeepInInsertMode =
True
Display_Ajax_Messagebox(
"Employee Leave cannot be inserted. Reason: " + e.Exception.Message, Me.RadAjaxManager)
Else
radgridEmployee_Costs.Controls.Add(
New LiteralControl(String.Format("<span style='color:red'>{0}</span>", "New Employee Leave Row Inserted.")))
End If
End Sub
' set up the required values before the update
Protected Sub radgridEmployees_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles radgridEmployees.UpdateCommand
' set the value of the commission percentage to an internal value
Dim editedItem As GridEditFormItem = e.Item
Dim txtCommissionPercentage As TextBox = editedItem.FindControl("txtCommission_Percentage")
If Not txtCommissionPercentage.Text = vbNullString Then
txtCommissionPercentage.Text = txtCommissionPercentage.Text / 100
End If
End Sub
' set up the required items for the edit / insert
Protected Sub radgridEmployee_Costs_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles radgridEmployee_Costs.ItemDataBound
If TypeOf e.Item Is GridEditFormItem And e.Item.IsInEditMode Then
Dim editedItem As GridEditFormInsertItem = CType(e.Item, GridEditFormInsertItem)
' disable the value of the employee_id
Dim txtEmployee_ID As TextBox = CType(editedItem("Employee_ID").Controls(0), TextBox)
txtEmployee_ID.Enabled =
False
End If
' disable the delete button for rows where there is an end date as only the last rows can be deleted
If e.Item.ItemType = GridItemType.AlternatingItem Or e.Item.ItemType = GridItemType.Item Then
Dim currentRow As System.Data.DataRowView = DirectCast(e.Item.DataItem, System.Data.DataRowView)
Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
If Not IsDBNull(currentRow.Row("End_Date")) Then
dataItem(
"DeleteColumn").Enabled = False
e.Item.BackColor = Drawing.Color.Yellow
End If
End If
End Sub
' display notification that an item has been deleted or the delete cant take place
Protected Sub radgridEmployees_ItemDeleted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDeletedEventArgs) Handles radgridEmployees.ItemDeleted
Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
Dim id As String = item.GetDataKeyValue("ID").ToString()
If Not e.Exception Is Nothing Then
e.ExceptionHandled =
True
Display_Ajax_Messagebox(
"Employee cannot be deleted. Reason: " + e.Exception.Message, Me.RadAjaxManager)
Else
Display_Ajax_Messagebox(
"Employee " + id + " Deleted.", Me.RadAjaxManager)
End If
End Sub
' display notification that an item has been deleted or if a delete cant take place
Protected Sub radgridEmployee_Costs_ItemDeleted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDeletedEventArgs) Handles radgridEmployee_Costs.ItemDeleted
Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
Dim id As String = item.GetDataKeyValue("ID").ToString()
If Not e.Exception Is Nothing Then
e.ExceptionHandled =
True
Display_Ajax_Messagebox(
"Employee Cost " + id + " cannot be deleted. Reason: " + e.Exception.Message, Me.RadAjaxManager)
Else
Display_Ajax_Messagebox(
"Employee Cost " + id + " Deleted.", Me.RadAjaxManager)
End If
End Sub
' display notification that an item has been deleted or if a delete cant take place
Protected Sub radgridEmployee_Leave_ItemDeleted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDeletedEventArgs) Handles radgridEmployee_Leave.ItemDeleted
Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
Dim id As String = item.GetDataKeyValue("ID").ToString()
If Not e.Exception Is Nothing Then
e.ExceptionHandled =
True
Display_Ajax_Messagebox(
"Employee Leave cannot be deleted. Reason: " + e.Exception.Message, Me.RadAjaxManager)
Else
Display_Ajax_Messagebox(
"Employee Leave " + id + " Deleted.", Me.RadAjaxManager)
End If
End Sub
' set up the required items for the edit / insert
Protected Sub radgridEmployee_Leave_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles radgridEmployee_Leave.ItemDataBound
If TypeOf e.Item Is GridEditFormItem And e.Item.IsInEditMode Then
' disable the value of the employee_id
Dim editedItem As GridEditFormItem = CType(e.Item, GridEditFormItem)
Dim txtEmployee_ID As TextBox = CType(editedItem("Employee_ID").Controls(0), TextBox)
txtEmployee_ID.Enabled =
False
End If
' disable the authorise and reject button for rows where the leave has already been authorised or rejected
If e.Item.ItemType = GridItemType.AlternatingItem Or e.Item.ItemType = GridItemType.Item Then
Dim currentRow As System.Data.DataRowView = DirectCast(e.Item.DataItem, System.Data.DataRowView)
Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
If Not IsDBNull(currentRow.Row("Authorised")) Then
If currentRow.Row("Authorised") = True Then
dataItem(
"Authorise").Enabled = False
dataItem(
"Reject").Enabled = False
dataItem(
"EditCommandColumn").Enabled = False
e.Item.BackColor = Drawing.Color.Yellow
End If
End If
If Not IsDBNull(currentRow.Row("Rejected")) Then
If currentRow.Row("Rejected") = True Then
dataItem(
"Authorise").Enabled = False
dataItem(
"Reject").Enabled = False
dataItem(
"EditCommandColumn").Enabled = False
e.Item.BackColor = Drawing.Color.Yellow
End If
End If
End If
End Sub
Protected Sub radgridEmployee_Leave_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles radgridEmployee_Leave.ItemCreated
If TypeOf e.Item Is GridEditFormInsertItem And Not e.Item.IsInEditMode Then
' disable the value of the employee_id
Dim editedItem As GridEditFormInsertItem = CType(e.Item, GridEditFormInsertItem)
Dim txtEmployee_ID As TextBox = CType(editedItem("Employee_ID").Controls(0), TextBox)
txtEmployee_ID.Enabled =
False
End If
End Sub
Public Sub raddpStart_Date_Leave_SelectedDateChanged(ByVal sender As Object, ByVal e As System.EventArgs)
'first reference the edited grid item through the NamingContainer attribute
Dim editedItem As GridEditableItem = CType(CType(sender, RadDatePicker).NamingContainer, GridEditableItem)
' set the min date for the end date calendar to the value of the start date calendar
Dim raddpStart_Date_Leave As RadDatePicker = CType(editedItem("Start_Date_Leave").FindControl("raddpStart_Date_Leave"), RadDatePicker)
Dim raddpEnd_Date_Leave As RadDatePicker = CType(editedItem("End_Date_Leave").FindControl("raddpEnd_Date_Leave"), RadDatePicker)
Dim txtHours As TextBox = CType(editedItem("Hours").FindControl("txtHours"), TextBox)
If raddpEnd_Date_Leave.SelectedDate <= raddpStart_Date_Leave.SelectedDate Then
raddpEnd_Date_Leave.MinDate = raddpStart_Date_Leave.DbSelectedDate
raddpEnd_Date_Leave.DbSelectedDate = raddpStart_Date_Leave.DbSelectedDate
End If
txtHours.Text = Determine_Leave_Hours(raddpStart_Date_Leave.DbSelectedDate, raddpEnd_Date_Leave.DbSelectedDate)
End Sub
Public Sub raddpEnd_Date_Leave_SelectedDateChanged(ByVal sender As Object, ByVal e As System.EventArgs)
'first reference the edited grid item through the NamingContainer attribute
Dim editedItem As GridEditableItem = CType(CType(sender, RadDatePicker).NamingContainer, GridEditableItem)
' set the min date for the end date calendar to the value of the start date calendar
Dim raddpStart_Date_Leave As RadDatePicker = CType(editedItem("Start_Date_Leave").FindControl("raddpStart_Date_Leave"), RadDatePicker)
Dim raddpEnd_Date_Leave As RadDatePicker = CType(editedItem("End_Date_Leave").FindControl("raddpEnd_Date_Leave"), RadDatePicker)
Dim txtHours As TextBox = CType(editedItem("Hours").FindControl("txtHours"), TextBox)
txtHours.Text = Determine_Leave_Hours(raddpStart_Date_Leave.DbSelectedDate, raddpEnd_Date_Leave.DbSelectedDate)
End Sub
'select the first row in every page if no row selected
Protected Sub radgridEmployees_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles radgridEmployees.PreRender
If radgridEmployees.SelectedIndexes.Count = 0 Then
If radgridEmployees.Items.Count > 0 Then
radgridEmployees.SelectedIndexes.Add(0)
radgridEmployee_Costs.DataBind()
radgridEmployee_Leave.DataBind()
End If
End If
End Sub
' set up the required items for the edit / insert
Protected Sub radgridEmployees_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles radgridEmployees.ItemDataBound
If TypeOf e.Item Is GridEditFormItem And e.Item.IsInEditMode Then
' disable the value of the employee_id
Dim editedItem As GridEditFormItem = CType(e.Item, GridEditFormItem)
Dim chkTerminated As CheckBox = CType(editedItem("Terminated").Controls(0), CheckBox)
chkTerminated.Enabled =
False
End If
End Sub
End Class
End
Namespace
Unfortunately I still can't reproduce the error. Could you please download the last version of the controls and see if the problem persists? I will also appreciate if you prepare a stripped working version of your project and send it attached to a formal support ticket. I will debug it locally and will get around to you with my findings.
Best regards,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center