Set Default Value To Drop Down List

sayali deshpande asked on April 14, 2016 13:29

Hi,

I am working on Kentico9. I have created one custom table. One field is "Active" Field having Boolean Data type, being boolean it should only have true or false values, but it is displaying "All" value By default. And I have set form control as drop-down list.

I want to set default value of drop-down list value as "True/False" not "All" . How can I achieve this?(In admin Section). I want this specifically so I could have specific records based on the boolean values itself instead of showing all records.

Recent Answers


Chetan Sharma answered on April 14, 2016 14:01

Hi Sayali,

Are you talking here about your form control or the form control that's set for a particular field type?

I created a new field of Boolean type and it's form control is automatically set to "Checkbox". This means that It will show me a checkbox type control for this particular field while trying to enter data for a custom table.

How are you generating this dropdown from a custom table? Are you using a custom table repeater? If yes, you could fetch data only for those records who value is "Yes" by setting it through the where clause of the repeater.

Let me know if this helps. I am attaching a screen shot for your reference

Custom table field reference

2 votesVote for this answer Mark as a Correct answer

sayali deshpande answered on April 14, 2016 14:20 (last edited on April 14, 2016 14:24)

I have created new field "Active" in custom table in fields section

I have checked screenshot sent by you. But In my case Default value is having checkbox not radio button.

My screenshot

Please check with this link.

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on April 14, 2016 17:16

Okay I got it. the difference between your and my settings was your field was required.

Click on the little arrow in front of arrow to set your values like

Yes;Yes
No;No

You will be okay after that. Attached screen shot. In the backend it will still store value as True/False

Let me know if it helps.

Cheers, Chetan

2 votesVote for this answer Mark as a Correct answer

Laura Frese answered on April 14, 2016 18:55

I would use the DropDownList form control then set the values in the drop down list form control settings like
1;Yes
0;No

http://pasteboard.co/buGim5M.jpg

2 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on April 14, 2016 21:03

Laura, from a usability perspective I will use a drop down when I'm trying to provide more than two options for a user to pick from. For binary choices radio buttons or check boxes are standard.

But I'm glad it helped Sayali.

Cheers Chetan

0 votesVote for this answer Mark as a Correct answer

Laura Frese answered on April 15, 2016 03:11

Id use a checkbox too, but Sayali was asking about drop down list

0 votesVote for this answer Mark as a Correct answer

sayali deshpande answered on April 15, 2016 09:18

Hi Chetan, I have tried the solution given by you. But it is not working in my case.

I am attaching screenshot please have a look. Currently when I entered in my module it display All records like this.link

But I want to display records which is having IsActive Value as "True" when I entered in my module. link

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on April 15, 2016 11:32

0 votesVote for this answer Mark as a Correct answer

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