Set Initial Value to a Drop Down List

lasa jay asked on January 18, 2017 07:06

Hi Kentico,

I would like to set a initial value to a drop down field within a Kentico form. The standard required field validation must fail if the user does not select any other options.

Basically, I am trying to imitate the initial value functionality provided by the RequiredFieldValidator in ASP .NET, please let me know if this is possible within Kentico forms.

Thanks in Advance!

Cheers, Lasa

Correct Answer

Jan Hermann answered on January 18, 2017 07:25

Set your field as Required and first row in your dropdown as:

;(Select)

2 votesVote for this answer Unmark Correct answer

Recent Answers


Ilesh Mistry answered on January 18, 2017 10:15

Exactly as Jan has said make sure the field is mandantory and have the first option as empty.

Better to create a query and then call this. This is so that, should you ever need to use that option again to feed another drop down, then something like the below could also help...

SELECT t.* FROM (SELECT '' as ItemId, '-- select --' as ItemDesc UNION
SELECT something as ItemId, something as ItemDesc FROM youTable) as t ORDER BY ItemId

Then within the drop down within the SQL Query option (data source) add a macro in to call that query (custom table for this example) e.g. {% GetCustomTableQueryText("Namespace.CustomTableName.QueryName")#%}

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.