Required Field validator with combobox

2 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    132 posts
    Member since:
    Sep 2007

    Posted 28 Mar 2011 Link to this post


    I've implemented a requiredfieldvalidator for a radcombobox which works fine on submitting the form, however I would like to show the red asterisk before the page is submitted to indicate to the user that the field is required.  Using


    in the Page_load event on the server activates the required field validators that are defined against text boxes, but I can't get the validator associated  with the combobox to show.

                <td><telerik:RadComboBox id="ddlCostCategory" DataTextField="Name" DataValueField="ID" runat="server" SkinID="WideDll"  ></telerik:RadComboBox></td>
                <td><asp:RequiredFieldValidator runat="server" ControlToValidate ="ddlCostCategory" ID="reqValCostCategory" Text="*" ErrorMessage="Cost Category is required" InitialValue="[Select...]" ></asp:RequiredFieldValidator></td>

    The combobox si bound to a list with the first item having the text of [Select...] before the Page.Validate is called:

    var query2 = from c in PNGC_SmartGridContext.CostCategories select c;
                   IList<CostCategory> _costCategories = query2.ToList<CostCategory>();
                   _costCategories.Insert(0, new CostCategory() { ID = 0, Name = "[Select...]" });
                   ddlCostCategory.DataSource = _costCategories;

    Note that the actual validation on submit works fine, it's just the ability to pre-trigger the red asterisk that would be great.


  2. Peter
    Peter avatar
    6637 posts

    Posted 31 Mar 2011 Link to this post

    Hello Jonathan,

    Instead of creating an item with Text="Select...", you can set EmptyMessage="Select..." and use the workaround suggested in this forum thread -

    I hope this helps.

    the Telerik team
Back to Top