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

validation problem

3 Answers 96 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
raphael
Top achievements
Rank 1
raphael asked on 30 Sep 2008, 02:26 PM
Hi I have a problem with combo boxes and validation.

I just putted a combobox and a requiredfieldvalidator on my form.
when I try to submit my form without compiling the combobox the alert shows up, but when I try to select a value from my combobox the dropdrown list does not show up.
here you have my code
<telerik:radcombobox
                            id="CompanyId"
                            Runat="server"
                            Height="140px"
                            Width="250px"
                            DataTextField="Name"
                            DataValueField="Id"
                            Skin="Office2007"
                            AllowCustomText = "true"
                            MarkFirstMatch="True"
                            OnDataBound="RadComboBox1_DataBound"
                            DataSourceID="odsgetCompany"
                            TabIndex="1" />
                        <asp:RequiredFieldValidator ID="rfvCmpanyId" ControlToValidate="CompanyId" runat="server" Text="*" ErrorMessage="Company" CssClass="error"/>

thank you for help

Raphael

3 Answers, 1 is accepted

Sort by
0
Serrin
Top achievements
Rank 1
answered on 30 Sep 2008, 06:58 PM
Hey Raphael,

Hmm, that is kinda weird.  I just tried using a similar setup (minus the CssClass and changing the datasource to my normal Linq to SQL datasource) and the validation worked fine, letting me set custom values as well as picking from the combobox.

Could you post more of your code?  The problem might not be in this section... (at least that is the best I can come up with right now since I can't reproduce the problem!).
0
raphael
Top achievements
Rank 1
answered on 01 Oct 2008, 06:26 AM
Hi serin,

I found out where the problem is, and now I have to find out the solution to my problem.

On my page I have some asp:panel these are used to show one form or another depending from the level of the treeview.

I tried to delete all panels and then the validation works fine. this is part of the code I use on my page, that gives me the problem.

<asp:Panel ID="Pnl1" runat="server" Visible="false">
    <telerik:radcombobox
        id="CompanyId"
        Runat="server"
        Height="140px"
        Width="250px"
        DataTextField="Name"
        DataValueField="Id"
        Skin="Office2007"
        AllowCustomText = "true"
        MarkFirstMatch="True"
        OnDataBound="RadComboBox1_DataBound"
        DataSourceID="odsgetCompany"
        TabIndex="1" />
    <asp:RequiredFieldValidator ID="rfvCmpanyId" ControlToValidate="CompanyId" runat="server" Text="*" ErrorMessage="Company" CssClass="error"/>
</asp:panel> 
 <asp:Panel ID="Pnl2" runat="server" Visible="false">
     <telerik:radcombobox
        id="InvestmentId"
        Runat="server"
        Height="140px"
        Width="250px"
        DataTextField="Name"
        DataValueField="Id"
        ToolTip="Select an Investment Family"
        Skin="Office2007"
        AllowCustomText = "true"
        MarkFirstMatch="True"
        DataSourceID="odsgetInvestment"/>
    <asp:RequiredFieldValidator ID="rfvFamily" ControlToValidate="InvestmentFamilyId" runat="server" Text="*" ErrorMessage="Investment" CssClass="error"/>
</asp:panel>
<asp:Button ID="btnSave" runat="server" Text="save" Visible="false" OnClick="btnSave_Click"/>
0
Atanas Korchev
Telerik team
answered on 01 Oct 2008, 04:56 PM
Hi raphael,

Have you checked this online example? It demonstrates how to use validators. Also have in mind that RadComboBox is validated by Text instead of Value. You may need to set the InitialValue property of your combobox.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
raphael
Top achievements
Rank 1
Answers by
Serrin
Top achievements
Rank 1
raphael
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or