Display blank record as default in drop-down in MVC
-
- Posts: 47
- Joined: September 7th, 2021, 1:04 pm
- Contact:
Display blank record as default in drop-down in MVC
I have a drop-down field which gets its values from a SQL table. How do I set it to default to a blank value vs. the first value in the list? In previous version in Appearance section, there was an option for "Default Text" which I set to blank and then "Show Default" which I set to Yes.
word count: 59
Tags:
-
- Posts: 571
- Joined: August 26th, 2021, 9:56 am
- Contact:
Re: Display blank record as default in drop-down in MVC
Hello Kathy,
Here are two examples to achieve the blank record as the first value in a DropDown control in MVC.
The first example uses a CreateServiceNode service and an Inquire service with the same name. The CreateServiceNode service creates the blank record by setting the name node to the result from the inquire that will be displayed in the Dropdown and nothing in the result node. Then the Inquire service will be setup with the "Append Service Output" property set to true to add the Inquire's results onto the CreateServiceNode results. This property is indicated by a purple dot in the top left corner of the service. The "Expose Service Output" property should also be set to true and is indicated by a green dot in the top left corner of the service. This property allows the controls to see that services output. Then in the Dropdown control set the Loop property to the "Result" node of the inquire service and the Text and Value properties to the column name from the inquire service.
The second example uses a CreateServiceNodeFromXml service and an Inquire service where the names don't have to be the same. The Inquire service is first in this example and is setup with only the "Expose Service Output" property set to true. Then the CreateServiceNodeFromXml service will contain a blank xml node with the column name. After the blank node add a XSLT for-each loop on the "Result" node of the inquire using the XSLT selector popup menu by clicking on the "Result" node from the Assistant tab. Inside the for-each loop add the same column name in xml and then add an XSLT value-of select on just the column name from the inquire service. Then in the Dropdown control set the Loop property to the Column Name node of the CreateServiceNodeFromXml service and the Text and Value properties to the same node.
Here are two examples to achieve the blank record as the first value in a DropDown control in MVC.
The first example uses a CreateServiceNode service and an Inquire service with the same name. The CreateServiceNode service creates the blank record by setting the name node to the result from the inquire that will be displayed in the Dropdown and nothing in the result node. Then the Inquire service will be setup with the "Append Service Output" property set to true to add the Inquire's results onto the CreateServiceNode results. This property is indicated by a purple dot in the top left corner of the service. The "Expose Service Output" property should also be set to true and is indicated by a green dot in the top left corner of the service. This property allows the controls to see that services output. Then in the Dropdown control set the Loop property to the "Result" node of the inquire service and the Text and Value properties to the column name from the inquire service.
The second example uses a CreateServiceNodeFromXml service and an Inquire service where the names don't have to be the same. The Inquire service is first in this example and is setup with only the "Expose Service Output" property set to true. Then the CreateServiceNodeFromXml service will contain a blank xml node with the column name. After the blank node add a XSLT for-each loop on the "Result" node of the inquire using the XSLT selector popup menu by clicking on the "Result" node from the Assistant tab. Inside the for-each loop add the same column name in xml and then add an XSLT value-of select on just the column name from the inquire service. Then in the Dropdown control set the Loop property to the Column Name node of the CreateServiceNodeFromXml service and the Text and Value properties to the same node.
word count: 484