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

Hierarchical RadGrid Validation

10 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JSON
Top achievements
Rank 1
JSON asked on 13 May 2010, 07:48 PM
I need to incorporate field level insert/update validation in the Master Table view and three detail views. So far I have added validation to one field on the master view but am at a loss. I have researched and tried several different solutions with no luck.

Would appreciate any help.

Thanks,

Steve O...

<%

@ Page Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="EditIncidents.aspx.cs" Inherits="CIMT.Forms.EditIncidents" Title="Edit Incidents" %>

 

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

 

<

 

asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

 

</

 

asp:Content>

 

<

 

asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

 

 

 

<div>

 

 

<h3 id="Add" style="text-align:left">Edit/Update/Delete Incidents</h3>

 

 

</div>

 

 

<div>

 

 

<telerik:RadGrid ID="RadGrid2"

 

 

runat="server"

 

 

GridLines="None"

 

 

DataSourceID="SqlDataSource11"

 

 

OnPageIndexChanged="dgIncidents_PageIndexChanged"

 

 

AllowAutomaticDeletes="True"

 

 

OnItemCreated="RadGrid2_ItemCreated"

 

 

AllowAutomaticInserts="True"

 

 

AllowAutomaticUpdates="True"

 

 

AllowPaging="True"

 

 

ShowStatusBar="True"

 

 

AutoGenerateColumns="False"

 

 

Skin="Simple" >

 

 

<ValidationSettings CommandsToValidate="PerformInsert,Update, Delete" EnableValidation="true" />

 

 

<%

-- Incidents --%>

 

 

<ValidationSettings ValidationGroup="gridGroup" />

 

 

<MasterTableView runat="server"

 

 

Name="Incidents"

 

 

Caption="Incidents"

 

 

DataSourceID="SqlDataSource11"

 

 

DataKeyNames="IncidentId"

 

 

CommandItemDisplay="Top"

 

 

ExpandCollapseColumn-ButtonType="ImageButton"

 

 

ExpandCollapseColumn-CollapseImageUrl="~/Images/zoom-out-icon[1].png"

 

 

ExpandCollapseColumn-ExpandImageUrl="~/Images/zoom-in-icon[1].png"

 

 

InsertItemPageIndexAction="ShowItemOnCurrentPage" >

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</RowIndicatorColumn>

 

<%

-- Units --%>

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</RowIndicatorColumn>

 

 

<EditFormSettings>

 

 

<EditColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"

 

 

CancelImageUrl="~/Images/stop-icon[1].png"

 

 

UpdateImageUrl="~/Images/accept-icon[1].png"

 

 

InsertImageUrl="~/Images/add-icon[2].png"

 

 

EditImageUrl="~/Images/edit-icon[1].png" >

 

 

</EditColumn>

 

 

</EditFormSettings>

 

 

<EditFormSettings>

 

 

<EditColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"

 

 

CancelImageUrl="~/Images/stop-icon[1].png"

 

 

UpdateImageUrl="~/Images/accept-icon[1].png"

 

 

InsertImageUrl="~/Images/add-icon[2].png"

 

 

EditImageUrl="~/Images/edit-icon[1].png" >

 

 

</EditColumn>

 

 

</EditFormSettings>

 

 

<DetailTables>

 

 

 

<telerik:GridTableView runat="server"

 

 

DataKeyNames="UnitId"

 

 

Name="Units"

 

 

Width="100%"

 

 

Caption="Units"

 

 

DataSourceID="SqlDataSource2"

 

 

BorderStyle="Solid"

 

 

BorderWidth="1px"

 

 

BorderColor="Blue"

 

 

CommandItemDisplay="Top"

 

 

ExpandCollapseColumn-ButtonType="ImageButton"

 

 

ExpandCollapseColumn-CollapseImageUrl="~/Images/zoom-out-icon[1].png"

 

 

ExpandCollapseColumn-ExpandImageUrl="~/Images/zoom-in-icon[1].png">

 

 

<ParentTableRelation>

 

 

<telerik:GridRelationFields MasterKeyField="IncidentId" DetailKeyField="IncidentId" />

 

 

</ParentTableRelation>

 

 

 

<ExpandCollapseColumn Visible="True"></ExpandCollapseColumn>

 

 

 

<EditFormSettings>

 

 

<EditColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"

 

 

CancelImageUrl="~/Images/stop-icon[1].png"

 

 

UpdateImageUrl="~/Images/accept-icon[1].png"

 

 

InsertImageUrl="~/Images/add-icon[2].png"

 

 

EditImageUrl="~/Images/edit-icon[1].png" >

 

 

</EditColumn>

 

 

</EditFormSettings>

 

 

<Columns>

 

 

 

<telerik:GridDropDownColumn DataField="UnitNameId"

 

 

DataSourceID="SqlDataSource3" DropDownControlType="DropDownList"

 

 

ListTextField="UnitName" ListValueField="UnitNameId" HeaderStyle-Font-Bold="true" UniqueName="UnitNameId"

 

 

HeaderText="Unit Name">

 

 

<HeaderStyle Font-Bold="True"></HeaderStyle>

 

 

</telerik:GridDropDownColumn>

 

 

<telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"

 

 

EditImageUrl="~/Images/edit-icon[1].png" ItemStyle-HorizontalAlign="Center">

 

 

<ItemStyle HorizontalAlign="Center"></ItemStyle>

 

 

</telerik:GridEditCommandColumn>

 

 

 

<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"

 

 

ButtonType="ImageButton" ImageUrl="~/Images/delete-icon[1].png" ItemStyle-HorizontalAlign="Center">

 

 

<ItemStyle HorizontalAlign="Center"></ItemStyle>

 

 

</telerik:GridButtonColumn>

 

 

</Columns>

 

 

<%

-- Unit Logs --%>

 

 

<DetailTables>

 

 

<telerik:GridTableView DataKeyNames="UnitLogId"

 

 

Name="UnitLogs"

 

 

Width="100%"

 

 

Caption="Unit Logs"

 

 

BorderStyle="Solid"

 

 

BorderWidth="1px"

 

 

DataSourceID="SqlDataSource1"

 

 

BorderColor="Blue"

 

 

CommandItemDisplay="Top"

 

 

ExpandCollapseColumn-ButtonType="ImageButton"

 

 

ExpandCollapseColumn-CollapseImageUrl="~/Images/zoom-out-icon[1].png"

 

 

ExpandCollapseColumn-ExpandImageUrl="~/Images/zoom-in-icon[1].png">

 

<%

-- AllowAutomaticDeletes="True"

 

AllowAutomaticInserts="True"

AllowAutomaticUpdates="True"

--

 

%>

 

 

<ParentTableRelation>

 

 

<telerik:GridRelationFields MasterKeyField="UnitId" DetailKeyField="UnitId" />

 

 

</ParentTableRelation>

 

 

 

<ExpandCollapseColumn Visible="True" ItemStyle-Wrap="false"></ExpandCollapseColumn>

 

 

<EditFormSettings>

 

 

<EditColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"

 

 

CancelImageUrl="~/Images/stop-icon[1].png"

 

 

UpdateImageUrl="~/Images/accept-icon[1].png"

 

 

InsertImageUrl="~/Images/add-icon[2].png"

 

 

EditImageUrl="~/Images/edit-icon[1].png" >

 

 

</EditColumn>

 

 

</EditFormSettings>

 

 

<Columns>

 

 

<telerik:GridDropDownColumn DataField="UnitLeaderId"

 

 

DataSourceID="SqlDataSource7" DropDownControlType="DropDownList"

 

 

ListTextField="Name" ListValueField="ResourceId"

 

 

HeaderStyle-Font-Bold="true" UniqueName="UnitLeaderId" HeaderText="Unit Leader">

 

 

<HeaderStyle Font-Bold="True"></HeaderStyle>

 

 

</telerik:GridDropDownColumn>

 

 

 

<telerik:GridDateTimeColumn DataField="UnitStartDate" DataType="System.DateTime"

 

 

HeaderText="Operation Start Date" HeaderStyle-Font-Bold="true" SortExpression="UnitStartDate"

 

 

UniqueName="UnitStartDate" PickerType="DateTimePicker">

 

 

<HeaderStyle Font-Bold="True"></HeaderStyle>

 

 

</telerik:GridDateTimeColumn>

 

 

 

<telerik:GridDateTimeColumn DataField="UnitEndDate" DataType="System.DateTime"

 

 

HeaderText="Operation End Date" HeaderStyle-Font-Bold="true" SortExpression="UnitEndDate"

 

 

UniqueName="UnitEndDate" PickerType="DateTimePicker">

 

 

<HeaderStyle Font-Bold="True"></HeaderStyle>

 

 

</telerik:GridDateTimeColumn>

 

 

 

<telerik:GridHyperLinkColumn ItemStyle-Font-Bold="true" ItemStyle-ForeColor="Blue"

 

 

Text="Assignments" NavigateUrl="~/Forms/Assignments.aspx" DataNavigateUrlFields="UnitLogId"

 

 

DataNavigateUrlFormatString="~/Forms/Assignments.aspx?UnitLogId={0}">

 

 

<ItemStyle Font-Bold="True" ForeColor="Blue"></ItemStyle>

 

 

</telerik:GridHyperLinkColumn>

 

 

 

<telerik:GridHyperLinkColumn ItemStyle-Font-Bold="true" ItemStyle-ForeColor="Blue"

 

 

Text="Activities" NavigateUrl="~/Forms/Activities.aspx" DataNavigateUrlFields="UnitLogId"

 

 

DataNavigateUrlFormatString="~/Forms/Activities.aspx?UnitLogId={0}">

 

 

<ItemStyle Font-Bold="True" ForeColor="Blue"></ItemStyle>

 

 

</telerik:GridHyperLinkColumn>

 

 

<telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"

 

 

EditImageUrl="~/Images/edit-icon[1].png" ItemStyle-HorizontalAlign="Center">

 

 

<ItemStyle HorizontalAlign="Center"></ItemStyle>

 

 

</telerik:GridEditCommandColumn>

 

 

 

<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"

 

 

ButtonType="ImageButton" ImageUrl="~/Images/delete-icon[1].png" ItemStyle-HorizontalAlign="Center">

 

 

<ItemStyle HorizontalAlign="Center"></ItemStyle>

 

 

</telerik:GridButtonColumn>

 

 

</Columns>

 

<%

-- Rosters --%>

 

 

<DetailTables>

 

 

<telerik:GridTableView runat="server"

 

 

DataKeyNames="RosterId"

 

 

Caption="Rosters"

 

 

Name="Rosters"

 

 

Width="100%"

 

 

DataSourceID="SqlDataSource4"

 

 

BorderStyle="Solid"

 

 

BorderWidth="1px"

 

 

BorderColor="Blue"

 

 

CommandItemDisplay="Top"

 

 

ExpandCollapseColumn-CollapseImageUrl="~/Images/zoom-out-icon[1].png"

 

 

ExpandCollapseColumn-ExpandImageUrl="~/Images/zoom-in-icon[1].png" >

 

 

 

<ParentTableRelation>

 

 

<telerik:GridRelationFields MasterKeyField="UnitLogId" DetailKeyField="UnitLogId" />

 

 

</ParentTableRelation>

 

 

<ExpandCollapseColumn ExpandImageUrl="~/Images/zoom-in-icon[1].png" CollapseImageUrl="~/Images/zoom-out-icon[1].png"></ExpandCollapseColumn>

 

 

<EditFormSettings>

 

 

<EditColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"

 

 

CancelImageUrl="~/Images/stop-icon[1].png"

 

 

UpdateImageUrl="~/Images/accept-icon[1].png"

 

 

InsertImageUrl="~/Images/add-icon[2].png"

 

 

EditImageUrl="~/Images/edit-icon[1].png" >

 

 

</EditColumn>

 

 

</EditFormSettings>

 

 

<Columns>

 

 

 

<telerik:GridDropDownColumn DataField="ResourceId"

 

 

DataSourceID="SqlDataSource5" DropDownControlType="DropDownList"

 

 

ListTextField="Name" HeaderStyle-Font-Bold="true" ListValueField="ResourceId" UniqueName="ResourceId" HeaderText="Resource">

 

 

<HeaderStyle Font-Bold="True"></HeaderStyle>

 

 

</telerik:GridDropDownColumn>

 

 

 

<telerik:GridDropDownColumn DataField="AgencyId"

 

 

DataSourceID="SqlDataSource8" DropDownControlType="DropDownList"

 

 

ListTextField="AgencyShort" HeaderStyle-Font-Bold="true" ListValueField="AgencyId" UniqueName="AgencyId" HeaderText="Agency">

 

 

<HeaderStyle Font-Bold="True"></HeaderStyle>

 

 

</telerik:GridDropDownColumn>

 

 

 

<telerik:GridDropDownColumn DataField="CallSignId"

 

 

DataSourceID="SqlDataSource6" DropDownControlType="DropDownList"

 

 

ListTextField="CallSign" HeaderStyle-Font-Bold="true" ListValueField="CallSignId" UniqueName="CallSignId" HeaderText="Call Sign">

 

 

<HeaderStyle Font-Bold="True"></HeaderStyle>

 

 

</telerik:GridDropDownColumn>

 

 

 

<telerik:GridBoundColumn DataField="Location" DataType="System.String"

 

 

HeaderText="Location" HeaderStyle-Font-Bold="true" SortExpression="Location" UniqueName="Location" Visible="true">

 

 

<HeaderStyle Font-Bold="True"></HeaderStyle>

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn DataField="Comments" DataType="System.String"

 

 

HeaderText="Comments" HeaderStyle-Font-Bold="true" SortExpression="Comments" UniqueName="Comments" Visible="true">

 

 

<HeaderStyle Font-Bold="True"></HeaderStyle>

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"

 

 

EditImageUrl="~/Images/edit-icon[1].png" ItemStyle-HorizontalAlign="Center">

 

 

<ItemStyle HorizontalAlign="Center"></ItemStyle>

 

 

</telerik:GridEditCommandColumn>

 

 

 

<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"

 

 

ButtonType="ImageButton" ImageUrl="~/Images/delete-icon[1].png" ItemStyle-HorizontalAlign="Center">

 

 

<ItemStyle HorizontalAlign="Center"></ItemStyle>

 

 

</telerik:GridButtonColumn>

 

 

</Columns>

 

 

<EditFormSettings>

 

 

<EditColumn UniqueName="EditCommandColumn1"></EditColumn>

 

 

</EditFormSettings>

 

 

</telerik:GridTableView>

 

 

</DetailTables>

 

 

<EditFormSettings>

 

 

<EditColumn UniqueName="EditCommandColumn1"></EditColumn>

 

 

</EditFormSettings>

 

 

</telerik:GridTableView>

 

 

</DetailTables>

 

 

<EditFormSettings>

 

 

<EditColumn UniqueName="EditCommandColumn1"></EditColumn>

 

 

</EditFormSettings>

 

 

</telerik:GridTableView>

 

 

</DetailTables>

 

 

 

<ExpandCollapseColumn CollapseImageUrl="~/Images/zoom-out-icon[1].png"

 

 

ExpandImageUrl="~/Images/zoom-in-icon[1].png">

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</ExpandCollapseColumn>

 

 

<Columns>

 

 

 

<telerik:GridBoundColumn DataField="IncidentId" DataType="System.Int32"

 

 

ReadOnly="True" SortExpression="IncidentId"

 

 

UniqueName="IncidentId" Visible="false">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="IncidentName" DataType="System.String"

 

 

SortExpression="IncidentId" UniqueName="IncidentName" HeaderText="Incident Name">

 

 

<HeaderStyle Font-Bold="True"></HeaderStyle>

 

 

<ItemStyle Width="200px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridDateTimeColumn DataField="OperationStartDate"

 

 

HeaderText="Start Date" UniqueName="StartDate" PickerType="DateTimePicker">

 

 

</telerik:GridDateTimeColumn>

 

 

<telerik:GridDateTimeColumn DataField="OperationEndDate" HeaderText="End Date"

 

 

UniqueName="EndDate" PickerType="DateTimePicker">

 

 

</telerik:GridDateTimeColumn>

 

 

<telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"

 

 

EditImageUrl="~/Images/edit-icon[1].png" ItemStyle-HorizontalAlign="Center">

 

 

<ItemStyle HorizontalAlign="Center"></ItemStyle>

 

 

</telerik:GridEditCommandColumn>

 

 

 

<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"

 

 

ButtonType="ImageButton" ImageUrl="~/Images/delete-icon[1].png" ItemStyle-HorizontalAlign="Center">

 

 

<ItemStyle HorizontalAlign="Center"></ItemStyle>

 

 

</telerik:GridButtonColumn>

 

 

</Columns>

 

 

<EditFormSettings>

 

 

<EditColumn InsertImageUrl="~/Images/add-icon[2].png"

 

 

EditImageUrl="~/Images/edit-icon[1].png"

 

 

CancelImageUrl="~/Images/close-icon[1].png">

 

 

</EditColumn>

 

 

</EditFormSettings>

 

 

<PagerStyle HorizontalAlign="Center" />

 

 

</MasterTableView>

 

 

</telerik:RadGrid>

 

 

</div>

 

<%

-- </ContentTemplate>

 

</asp:UpdatePanel>--

 

%>

 

<%

-- DataSources --%>

 

 

 

<asp:SqlDataSource ID="SqlDataSource7" runat="server"

 

 

ConnectionString="<%$ ConnectionStrings:CIMT %>" EnableCaching="true"

 

 

SelectCommand="select ResourceId, Name from CIMT_V_Resources order by 2">

 

 

</asp:SqlDataSource>

 

 

 

<asp:SqlDataSource ID="SqlDataSource3" runat="server"

 

 

ConnectionString="<%$ ConnectionStrings:CIMT %>" EnableCaching="true"

 

 

SelectCommand="select UnitNameId, UnitName from CIMT_LU_UnitNames order by 2">

 

 

</asp:SqlDataSource>

 

 

 

<asp:SqlDataSource ID="SqlDataSource5" runat="server" EnableCaching="true"

 

 

ConnectionString="<%$ ConnectionStrings:CIMT %>"

 

 

SelectCommand="select ResourceId, Name from CIMT_V_Resources order by 2">

 

 

</asp:SqlDataSource>

 

 

<asp:SqlDataSource ID="SqlDataSource6" runat="server"

 

 

ConnectionString="<%$ ConnectionStrings:CIMT %>"

 

 

SelectCommand="select CallSignId, CallSign from CIMT_V_CallSigns order by 2">

 

 

</asp:SqlDataSource>

 

 

<asp:SqlDataSource ID="SqlDataSource8" runat="server"

 

 

ConnectionString="<%$ ConnectionStrings:CIMT %>"

 

 

SelectCommand="select AgencyId, AgencyShort from CIMT_LU_Agencies order by 2">

 

 

</asp:SqlDataSource>

 

 

<asp:SqlDataSource ID="SqlDataSource9" runat="server"

 

 

ConnectionString="<%$ ConnectionStrings:CIMT %>"

 

 

SelectCommand="select distinct IncidentId, IncidentName from CIMT_T_Incidents

 

union select '' IncidentId, '' IncidentName from CIMT_T_Incidents order by 2">

 

</asp:SqlDataSource>

 

 

 

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

 

 

ConnectionString="<%$ ConnectionStrings:CIMT %>"

 

 

DeleteCommand="DELETE FROM [CIMT_T_UnitLog] WHERE [UnitLogId] = @UnitLogId"

 

 

InsertCommand="INSERT INTO [CIMT_T_UnitLog] ([UnitId], [UnitLeaderId], [UnitStartDate], [UnitEndDate]) VALUES (@UnitId, @UnitLeaderId, @UnitStartDate, @UnitEndDate)"

 

 

SelectCommand="SELECT [UnitLogId], [UnitId], [UnitLeaderId], [UnitStartDate], [UnitEndDate] FROM [CIMT_T_UnitLog] WHERE [UnitId] = @UnitId"

 

 

UpdateCommand="UPDATE [CIMT_T_UnitLog] SET [UnitLeaderId] = @UnitLeaderId, [UnitStartDate] = @UnitStartDate, [UnitEndDate] = @UnitEndDate WHERE [UnitLogId] = @UnitLogId">

 

 

<SelectParameters>

 

 

<asp:Parameter Name="UnitId" Type="Int32" />

 

 

</SelectParameters>

 

 

<DeleteParameters>

 

 

<asp:Parameter Name="UnitLogId" Type="Int32" />

 

 

</DeleteParameters>

 

 

<UpdateParameters>

 

 

<asp:Parameter Name="UnitId" Type="Int32" />

 

 

<asp:Parameter Name="UnitLeaderId" Type="Int32" />

 

 

<asp:Parameter DbType="DateTime" Name="UnitStartDate" />

 

 

<asp:Parameter DbType="DateTime" Name="UnitEndDate" />

 

 

<asp:Parameter Name="UnitLogId" Type="Int32" />

 

 

</UpdateParameters>

 

 

<InsertParameters>

 

 

<asp:Parameter Name="UnitId" Type="Int32" />

 

 

<asp:Parameter Name="UnitLeaderId" Type="Int32" />

 

 

<asp:Parameter DbType="DateTime" Name="UnitStartDate" />

 

 

<asp:Parameter DbType="DateTime" Name="UnitEndDate" />

 

 

</InsertParameters>

 

 

</asp:SqlDataSource>

 

 

 

<asp:SqlDataSource ID="SqlDataSource2" runat="server"

 

 

ConnectionString="<%$ ConnectionStrings:CIMT %>"

 

 

DeleteCommand="DELETE FROM [CIMT_T_Units] WHERE [UnitId] = @UnitId"

 

 

InsertCommand="INSERT INTO [CIMT_T_Units] ([IncidentId], [UnitNameId]) VALUES (@IncidentId, @UnitNameId)"

 

 

SelectCommand="SELECT [UnitId], [IncidentId], [UnitNameId] FROM [CIMT_T_Units] WHERE [IncidentId] = @IncidentId"

 

 

UpdateCommand="UPDATE [CIMT_T_Units] SET [UnitNameId] = @UnitNameId WHERE [UnitId] = @UnitId">

 

 

<SelectParameters>

 

 

<asp:Parameter Name="IncidentId" Type="Int32" />

 

 

</SelectParameters>

 

 

<DeleteParameters>

 

 

<asp:Parameter Name="UnitId" Type="Int32" />

 

 

</DeleteParameters>

 

 

<UpdateParameters>

 

 

<asp:Parameter Name="IncidentId" Type="Int32" />

 

 

<asp:Parameter Name="UnitNameId" Type="Int32" />

 

 

<asp:Parameter Name="UnitId" Type="Int32" />

 

 

</UpdateParameters>

 

 

<InsertParameters>

 

 

<asp:Parameter Name="IncidentId" Type="Int32" />

 

 

<asp:Parameter Name="UnitNameId" Type="Int32" />

 

 

</InsertParameters>

 

 

</asp:SqlDataSource>

 

 

 

<asp:SqlDataSource ID="SqlDataSource4" runat="server"

 

 

ConnectionString="<%$ ConnectionStrings:CIMT %>"

 

 

DeleteCommand="DELETE FROM [CIMT_T_Rosters] WHERE [RosterId] = @RosterId"

 

 

InsertCommand="INSERT INTO [CIMT_T_Rosters] ([UnitLogId], [AgencyId], [CallSignId], [ResourceId], [ContactInfo], [VehicleIdentifier], [Location], [Comments]) VALUES (@UnitLogId, @AgencyId, @CallSignId, @ResourceId, @ContactInfo, @VehicleIdentifier, @Location, @Comments)"

 

 

SelectCommand="SELECT [RosterId], [UnitLogId], [AgencyId], [CallSignId], [ResourceId], [ContactInfo], [VehicleIdentifier], [Location], [Comments] FROM [CIMT_T_Rosters] WHERE [UnitLogId] = @UnitLogId"

 

 

UpdateCommand="UPDATE [CIMT_T_Rosters] SET [AgencyId] = @AgencyId, [CallSignId] = @CallSignId, [ResourceId] = @ResourceId, [ContactInfo] = @ContactInfo, [VehicleIdentifier] = @VehicleIdentifier, [Location] = @Location, [Comments] = @Comments WHERE [RosterId] = @RosterId">

 

 

<SelectParameters>

 

 

<asp:Parameter Name="UnitLogId" Type="Int32" />

 

 

</SelectParameters>

 

 

<DeleteParameters>

 

 

<asp:Parameter Name="RosterId" Type="Int32" />

 

 

</DeleteParameters>

 

 

<UpdateParameters>

 

 

<asp:Parameter Name="UnitLogId" Type="Int32" />

 

 

<asp:Parameter Name="AgencyId" Type="Int32" />

 

 

<asp:Parameter Name="CallSignId" Type="Int32" />

 

 

<asp:Parameter Name="ResourceId" Type="Int32" />

 

 

<asp:Parameter Name="ContactInfo" Type="String" />

 

 

<asp:Parameter Name="VehicleIdentifier" Type="String" />

 

 

<asp:Parameter Name="Location" Type="String" />

 

 

<asp:Parameter Name="Comments" Type="String" />

 

 

<asp:Parameter Name="RosterId" Type="Int32" />

 

 

</UpdateParameters>

 

 

<InsertParameters>

 

 

<asp:Parameter Name="UnitLogId" Type="Int32" />

 

 

<asp:Parameter Name="AgencyId" Type="Int32" />

 

 

<asp:Parameter Name="CallSignId" Type="Int32" />

 

 

<asp:Parameter Name="ResourceId" Type="Int32" />

 

 

<asp:Parameter Name="ContactInfo" Type="String" />

 

 

<asp:Parameter Name="VehicleIdentifier" Type="String" />

 

 

<asp:Parameter Name="Location" Type="String" />

 

 

<asp:Parameter Name="Comments" Type="String" />

 

 

</InsertParameters>

 

 

</asp:SqlDataSource>

 

 

<asp:SqlDataSource ID="SqlDataSource11" runat="server"

 

 

ConnectionString="<%$ ConnectionStrings:CIMTConnectionString %>"

 

 

DeleteCommand="DELETE FROM [CIMT_T_Incidents] WHERE [IncidentID] = @IncidentID"

 

 

InsertCommand="INSERT INTO [CIMT_T_Incidents] ([IncidentName], [OperationStartDate], [OperationEndDate]) VALUES (@IncidentName, @OperationStartDate, @OperationEndDate)"

 

 

SelectCommand="SELECT [IncidentID], [IncidentName], [OperationStartDate], [OperationEndDate] FROM [CIMT_T_Incidents]"

 

 

UpdateCommand="UPDATE [CIMT_T_Incidents] SET [IncidentName] = @IncidentName, [OperationStartDate] = @OperationStartDate, [OperationEndDate] = @OperationEndDate WHERE [IncidentID] = @IncidentID">

 

 

<DeleteParameters>

 

 

<asp:Parameter Name="IncidentID" Type="Int32" />

 

 

</DeleteParameters>

 

 

<UpdateParameters>

 

 

<asp:Parameter Name="IncidentName" Type="String" />

 

 

<asp:Parameter DbType="DateTime" Name="OperationStartDate" />

 

 

<asp:Parameter DbType="DateTime" Name="OperationEndDate" />

 

 

<asp:Parameter Name="IncidentID" Type="Int32" />

 

 

</UpdateParameters>

 

 

<InsertParameters>

 

 

<asp:Parameter Name="IncidentName" Type="String" />

 

 

<asp:Parameter DbType="DateTime" Name="OperationStartDate" />

 

 

<asp:Parameter DbType="DateTime" Name="OperationEndDate" />

 

 

</InsertParameters>

 

 

</asp:SqlDataSource>

 

</

 

asp:Content>

------------------------------------------------------------------------------------------------------------

 

using

 

System;

 

 

 

using

 

System.Collections;

 

 

 

using

 

System.Configuration;

 

 

 

using

 

System.Data;

 

 

 

using

 

System.Linq;

 

 

 

using

 

System.Web;

 

 

 

using

 

System.Web.Security;

 

 

 

using

 

System.Web.UI;

 

 

 

using

 

System.Web.UI.WebControls;

 

 

 

using

 

System.Web.UI.WebControls.WebParts;

 

 

 

using

 

System.Web.UI.HtmlControls;

 

 

 

using

 

System.Xml.Linq;

 

 

 

using

 

Telerik;

 

 

 

using

 

Telerik.Web.UI;

 

 

 

namespace

 

CIMT.Forms

 

{

 

public partial class EditIncidents : System.Web.UI.Page

 

 

 

 

{

 

protected void Page_Load(object sender, EventArgs e)

 

{

}

 

protected void dtUnitLogs_SelectedIndexChanged(object sender, EventArgs e)

 

{

 

// int UnitLogId = int.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["UnitLogId"].ToString());

 

 

 

 

 

// Session["UnitLogId"] = UnitLogId;

 

 

 

 

}

 

protected void dgIncidents_PageIndexChanged(object sender, GridPageChangedEventArgs e)

 

{

RadGrid2.CurrentPageIndex = e.NewPageIndex;

}

 

//protected void RadGrid2_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)

 

 

 

 

 

//{

 

 

 

 

 

// if ((e.Item is GridEditFormInsertItem) && (RadGrid2.MasterTableView.IsItemInserted))

 

 

 

 

 

// {

 

 

 

 

 

// GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;

 

 

 

 

 

// RadDateTimePicker sDate = (RadDateTimePicker)insertItem["StartDate"].Controls[0];

 

 

 

 

 

// sDate.SelectedDate = DateTime.Now;

 

 

 

 

 

// insertItem = (GridEditFormInsertItem)e.Item;

 

 

 

 

 

// RadDateTimePicker eDate = (RadDateTimePicker)insertItem["EndDate"].Controls[0];

 

 

 

 

 

// eDate.SelectedDate = DateTime.Now;

 

 

 

 

 

// }

 

 

 

 

 

//}

 

 

 

 

 

protected void RadGrid2_ItemCreated(object sender, GridItemEventArgs e)

 

{

 

if (e.Item is GridEditableItem && e.Item.IsInEditMode)

 

{

 

string tabName = e.Item.OwnerTableView.Name.ToString();

 

 

GridEditableItem item;

 

 

GridDateTimeColumnEditor rdtEditor;

 

 

GridDropDownColumn ddc;

 

 

DropDownList ddl;

 

 

TableCell cell;

 

 

GridDateTimeColumn rdt;

 

 

RequiredFieldValidator validator = new RequiredFieldValidator();

 

validator.ErrorMessage =

"* Value Required";

 

item = e.Item

as GridEditableItem;

 

 

switch (tabName)

 

{

 

case "Incidents":

 

 

GridTextBoxColumnEditor tbEditor;

 

tbEditor = (

GridTextBoxColumnEditor)item.EditManager.GetColumnEditor("IncidentName");

 

cell = (

TableCell)tbEditor.TextBoxControl.Parent;

 

tbEditor.TextBoxControl.ID =

"IncidentName";

 

validator.ControlToValidate = tbEditor.TextBoxControl.ID;

cell.Controls.Add(validator);

rdtEditor = (

GridDateTimeColumnEditor)item.EditManager.GetColumnEditor("StartDate");

 

cell = (

TableCell)tbEditor.TextBoxControl.Parent;

 

rdtEditor.PickerControl.ID =

"StartDate";

 

validator.ControlToValidate = rdtEditor.PickerControl.ID;

cell.Controls.Add(validator);

rdtEditor = (

GridDateTimeColumnEditor)item.EditManager.GetColumnEditor("EndDate");

 

cell = (

TableCell)tbEditor.TextBoxControl.Parent;

 

rdtEditor.PickerControl.ID =

"EndDate";

 

validator.ControlToValidate = rdtEditor.PickerControl.ID;

cell.Controls.Add(validator);

 

break;

 

 

case "Units":

 

 

break;

 

 

case "UnitLogs":

 

 

break;

 

 

case "Rosters":

 

 

break;

 

 

default:

 

 

break;

 

}

 

}

}

10 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 14 May 2010, 11:53 AM
Hi Steve,

Please refer to Flexible Server-side Validation example which demonstrates the flexible server-side validation mechanism of the Telerik RadGrid edit form.

I hope this gets you started properly.

Regards,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
JSON
Top achievements
Rank 1
answered on 14 May 2010, 12:35 PM
As you can see from the code I provided, that is what I have tried (Flexable server-side Validation) without success. It is keyed off of an exception which does not happen, i.e. insert a record with no data.  Is there a field attribute setting I am missing to trigger an exception or what?

Understand I have three detail table views with multiple fields in them that all require validation.

Thank you,

Steve O...
0
Pavlina
Telerik team
answered on 14 May 2010, 04:49 PM
Hello Steve,

Unfortunately I could not reproduce the issue on the live site. At this point in order to find a quick solution/fix I will ask you to open a formal support ticket and send us a simple working test project which demonstrates the issue. Thus I could do my best to help you further in resolving it.

Sincerely yours,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
JSON
Top achievements
Rank 1
answered on 17 May 2010, 02:58 PM

Hello,

 

I found the problem I was having in the previous post - my fault. But now I have an issue validating GridDropDownList - it does not validate as other controls do. I have created a custom validator in the code behind but it does not fire when no value selected.


Thank you,

Steve O...

 

 

<telerik:RadGrid ID="RadGrid2"

 

runat="server"

 

GridLines="None"

 

DataSourceID="SqlDataSource11"

 

OnPageIndexChanged="dgIncidents_PageIndexChanged"

 

AllowAutomaticDeletes="True"

 

AllowAutomaticInserts="True"

 

AllowAutomaticUpdates="True"

 

OnItemInserted="RadGrid2_ItemInserted"

 

OnItemUpdated="RadGrid2_ItemUpdated"

 

OnDataBound="RadGrid2_DataBound"

 

AllowPaging="True"

 

ShowStatusBar="True"

 

AutoGenerateColumns="False"

 

Skin="Simple" >

 

 

 

 

 

<ValidationSettings CommandsToValidate="PerformInsert,Insert,Update,Delete"

 

EnableValidation="true" ValidationGroup="FormValidationGroup" />

 

 

 

 

------------------------------------------------------------------------------------------------------- 

 

 

 

<telerik:GridDropDownColumn DataField="UnitNameId"

DataSourceID="SqlDataSource3" DropDownControlType="DropDownList"

ListTextField="UnitName" ListValueField="UnitNameId" HeaderStyle-Font-Bold="true" UniqueName="UnitNameId"

HeaderText="Unit Name">

<HeaderStyle Font-Bold="True"></HeaderStyle>

</telerik:GridDropDownColumn>

 ----------------------------------------------------------------------------------------

 

GridDropDownColumnEditor editor = (GridDropDownColumnEditor)item.EditManager.GetColumnEditor("UnitNameId");

DropDownList ddl = (DropDownList)((Telerik.Web.UI.GridDropDownListColumnEditor)(editor)).DropDownListControl;

TableCell cell = (TableCell)ddl.Parent;

ddl.ID =

 

"UnitNameId";

 

 

ddl.AutoPostBack =

true;

 

ddl.CausesValidation =

 

true;

 

 

 

 

 


RequiredFieldValidator
validator = new RequiredFieldValidator();

 

 

 

validator.ControlToValidate = ddl.ID;

validator.ErrorMessage =

 

" * Unit Name Value Required";

 

 

cell.Controls.Add(validator);

 

 

 

 

 

 

 

 

0
Pavlina
Telerik team
answered on 19 May 2010, 11:32 AM
Hello Steve,

Please examine the code from the forum thread below, which shows how to validate the DropDownList control inside built-in GridDropDownColumn and let me know if it helps to resolve the issue:
http://www.telerik.com/community/forums/aspnet-ajax/grid/grid-dropdown-list-validation-error.aspx

Kind regards,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
JSON
Top achievements
Rank 1
answered on 19 May 2010, 12:38 PM
Hello,

I used the provided example and the record is still allowed to create with no error message displayed.

Thanks,

Steve O...

 

<telerik:RadGrid ID="RadGrid2"

 

 

runat="server"

 

 

GridLines="None"

 

 

DataSourceID="SqlDataSource11"

 

 

OnPageIndexChanged="dgIncidents_PageIndexChanged"

 

 

AllowAutomaticDeletes="True"

 

 

AllowAutomaticInserts="True"

 

 

AllowAutomaticUpdates="True"

 

 

AllowPaging="True"

 

 

ShowStatusBar="True"
OnItemInserted="RadGrid2_ItemInserted"

 

 

AutoGenerateColumns="False"

 

 

Skin="Simple">

 

 


<
ValidationSettings EnableValidation="true" ValidationGroup="DropDownValidate" />

 

 



 

GridEditableItem item = e.Item as GridEditableItem;

 

 

GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)item.EditManager.GetColumnEditor("UnitNameId");

 

 

DropDownList ddl = editor.DropDownListControl;

 

ddl.ValidationGroup =

"DropDownValidate";

 

 

TableCell cell = (TableCell)ddl.Parent;

 

validator.ControlToValidate = ddl.ID;

validator.ErrorMessage =

" * Unit Name Value Required";

 

validator.Text =

"*";

 

validator.InitialValue =

"";

 

validator.ValidationGroup =

"DropDownValidate";

 

cell.Controls.Add(validator);

0
Pavlina
Telerik team
answered on 25 May 2010, 08:54 AM
Hi Steve,

Could you please open a formal support ticket and send us a small runnable project which demonstrates the described issue. We will review it locally and advise you further.

Thank you in advance for your cooperation.

Regards,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
JSON
Top achievements
Rank 1
answered on 25 May 2010, 01:43 PM
I just need to know how to identify what level was selected in the grid. In other words, when a user drills down to a specific detail view then navigates to another page via a hyperlink. How can I determine where they last were when returning to the original page - so I can expand the grid accordingly.

I have attached a pic of my application for your reference if that helps.

Thank you,

Steve O...

0
JSON
Top achievements
Rank 1
answered on 25 May 2010, 02:40 PM
I decided to display the called pages as popups to resolve my issue. I would still like to know about my previous question.

Thank you,

Steve O...
0
Pavlina
Telerik team
answered on 28 May 2010, 01:15 PM
Hello Steve,

Can you, please, open a regular support ticket where you can provide us with a sample runnable project demonstrating this issue? Once we are able to identify the cause for that, we will be able to assist you better.

Additionally I suggest that you review the help article below:
http://www.telerik.com/help/aspnet-ajax/grdvalidation.html

Greetings,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
JSON
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
JSON
Top achievements
Rank 1
Share this question
or