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

Colors disapear by using validation group

1 Answer 33 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Bader
Top achievements
Rank 1
Bader asked on 26 Jul 2011, 05:33 PM

Hello,

I have two problems using the RadComboBox control.
1. I'm using the radgrid control that handles the insert, update and delete operations (using user control).
The user control has a radcombobox control that Displays two columns: color and value.

In normal situation where no validation controls are exist in the user control, the radComboBox control displays as it should be (Please view the attached screenshot).
If I add validation group to the user control then the error occures.
Please follow the steps below in order to show you the problem.
1) Click add new record.
2) Click on the radcombobox control (The result is shown in the attached screenshot1).
3) click "Add", then the validation error messages must appear.(dont fill in the Name field)
4) Click on the radcombobox control (The result is shown in the attached screenshot1 - No color appear).

2. As you can see there is a compare validator for the radcombobox (No "Select Color" item is exist).
How can I verify that the user select one color from the list (No selection must show an error message).

Here is the usercontrol content:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SubUserControl.ascx.cs" Inherits="IsraelOnTheMap.SecureSiteManagenment_Pages_SecureSQLServer_Ctgrs_SubUserControl" %>
 
<link rel="stylesheet" type="text/css" href="../../../../Common/Controls/RadEditor/RTLRadEditorStyle/Editor_RTL.css" />
<link rel="stylesheet" type="text/css" href="../../../Design/Style/SecureManagenmentStyle.css" />
 
<asp:Panel ID="SubPanel" runat="server" style="margin:10px;">
    <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="1" rules="none"
        style="BORDER-COLLAPSE: collapse">
        <tr id="LastVisitDateTr" align="<%$ Resources:MngResource, ContentFloat %>" runat="server">
            <td colspan="2">
                <asp:Panel ID="LastModifyPanel" runat="server" HorizontalAlign="<%$ Resources:MngResource, NoContentFloat %>" Visible='<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) ? false : true %>' Width="100%">
                    <asp:Label ID="LastModifyByTextLabel" runat="server" Visible="false" Font-Bold="true" Text="<%$ Resources:MngResource, LastModifyBy %>" ></asp:Label>
                    <asp:Label ID="LastModifyByIDLabel" runat="server" Visible="false" Text='<%#  DataBinder.Eval( Container, "DataItem.UserName" ) %>'></asp:Label>
                    <asp:Label ID="LastModifyDateTextLabel" runat="server" Font-Bold="true" Text="<%$ Resources:MngResource, LastModifyDate %>" ></asp:Label>
                    <asp:Label ID="LastModifyDateLabel" runat="server" Text='<%#  DataBinder.Eval( Container, "DataItem.LastModifyDate" ) %>'></asp:Label>
                </asp:Panel>
            </td>
        </tr>
        <tr id="DataFieldsTr" align="<%$ Resources:MngResource, ContentFloat %>" runat="server">
        <td>
            <table id="Table3" cellspacing="1" cellpadding="1" width="100%" border="0">
                <tr>
                    <td></td>
                    <td></td>
                </tr>
                <tr runat="server" Visible='<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) ? false : true %>'>
                    <td>
                        <asp:Label ID="CtgryIDLabel" runat="server" Text="<%$ Resources:MngResource, PagesSecureSqlServerCtgrsRadGridUserControlCtgryIDLabel %>"></asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="CtgryIDDataLabel" runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.CtgryID" ) %>'></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="CtgryNameLabel" runat="server" Text="<%$ Resources:MngResource, PagesSecureSqlServerCtgrsRadGridUserControlCtgryNameLabel %>"></asp:Label>
                    </td>
                    <td>
                        <telerik:RadTextBox ID="CtgryNameDataRadTextBox" runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.CtgryName" ) %>' Width="201px" ValidationGroup="CtgrsMngValidationGroup">
                        </telerik:RadTextBox>
                        <asp:RequiredFieldValidator ID="CtgryNameRequiredFieldValidator" runat="server"
                                    ControlToValidate="CtgryNameDataRadTextBox"
                                    SkinID="NormalRequiredFieldValidator"
                                    ErrorMessage="<%$ Resources:MngResource, PagesSecureSqlServerCtgrsRadGridUserControlCtgryNameRequiredFieldValidatorErrorMessage %>"
                                    ValidationGroup="CtgrsMngValidationGroup" ></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="CtgryColrLabel" runat="server" Text="<%$ Resources:MngResource, PagesSecureSqlServerCtgrsRadGridUserControlCtgryColrLabel %>"></asp:Label>
                    </td>
                    <td>
                        <asp:XmlDataSource ID="CtgrsXmlDataSource" runat="server" DataFile="~/Pages/Design/xml/Ctgrs.xml" >
                        </asp:XmlDataSource>
                        <telerik:RadComboBox ID="CtgryColrRadComboBox" runat="server" DataSourceID="CtgrsXmlDataSource"
                            DataValueField="Value" DataTextField="Text" SelectedValue='<%# DataBinder.Eval( Container, "DataItem.CtgryColr" ) %>' HighlightTemplatedItems="true"
                            AllowCustomText="true" Width="205px" style="z-index:10000;" ValidationGroup="CtgrsMngValidationGroup">
                            <ItemTemplate>
                                 <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                   <tr>
                                     <td style="width:20%;">
                                         <asp:Panel ID="Panel1" BorderWidth="1px" Height="12px" Width="12px" BackColor='<%# System.Drawing.Color.FromName("#" + Eval("Value").ToString()) %>' runat="server">
                                         </asp:Panel>
                                     </td>
                                     <td style="width:80%;">
                                         <asp:Label ID="Label2" runat="server" Text='<%# "#" + Eval("Value").ToString() %>'></asp:Label>
                                     </td>
                                   </tr>
                                 </table>
                            </ItemTemplate>
                        </telerik:RadComboBox>
                        <asp:CompareValidator ID="CtgryColrRequiredFirstNameValidator" runat="server"
                                    ControlToValidate="CtgryColrRadComboBox" Type="String" Operator="NotEqual"
                                    SkinID="NormalRequiredFieldValidator" ValueToCompare=" "
                                    ErrorMessage="<%$ Resources:MngResource, PagesSecureSqlServerCtgrsRadGridUserControlCtgryColrRequiredFirstNameValidatorErrorMessage %>"
                                    ValidationGroup="CtgrsMngValidationGroup" ></asp:CompareValidator>
                    </td>
                </tr>
             </table>
           </td>
       </tr>
       <tr>
            <td id="Td1" align="<%$ Resources:MngResource, NoContentFloat %>" runat="server" colspan="2">
                <asp:button id="btnUpdate" text="<%$ Resources:GeneralTelerikResource, TelerikRadGridEditFormUpdateButtonText %>" runat="server" CommandName="Update" Visible='<%# !(DataBinder.Eval( Container, "DataItem") is Telerik.Web.UI.GridInsertionObject) %>' ValidationGroup="CtgrsMngValidationGroup"></asp:button>
                <asp:button id="btnInsert" text="<%$ Resources:GeneralTelerikResource, TelerikRadGridEditFormInsertButtonText %>" runat="server" CommandName="PerformInsert" Visible='<%# DataBinder.Eval( Container, "DataItem") is Telerik.Web.UI.GridInsertionObject %>' ValidationGroup="CtgrsMngValidationGroup"></asp:button>
                  
                <asp:button id="btnCancel" text="<%$ Resources:GeneralTelerikResource, TelerikRadGridEditFormCancelButtonText %>" runat="server" causesvalidation="False" commandname="Cancel"></asp:button>
            </td>
        </tr>
   </table>
</asp:Panel>

Please, I need your help.
It is very appreciated to send me the modified code.

Regards,
Bader

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 29 Jul 2011, 12:01 PM
Hello Bader,

In order to ensure that an existing item has been selected from the RadComboBox, my suggestion is to use the approach from this help article here.

Additionally you could change your CompareValidator with a CustomValidator which will use the approach from the help article as well.

Regarding you problem with the missing colors, it appears that the binding expression is not evaluated properly the second time. If you overcome the problem with the validation I presume that this problem should be fixed as well, since you won't be able to make a post-back unless the required data is populated correctly in the edit form of the RadGrid.

Best wishes,
Dimitar Terziev
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
ComboBox
Asked by
Bader
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or