Navigation: DbNetComboCore >

Properties

 

 

 

 

AutoRowSelect (boolean)

 

Selects the first option in a combo where the Size is greater than 1

 

...

DbNetComboCore territoriesCombo = new DbNetComboCore("northwind", "territories", "territoryid", "territorydescription", "territories") { ForeignKeyColumn = "regionid", Size = 10, MultipleSelect = true, AutoRowSelect = true };

DbNetComboCore regionsCombo = new DbNetComboCore("northwind", "regions", "regionid", "regiondescription", "regions") { Size = 10, MultipleSelect = true, AutoRowSelect = true };

territoriesCombo.AddLinkedControl(employeesGrid);

regionsCombo.AddLinkedControl(territoriesCombo);

@regionsCombo.Render()

...

 

Demo

 

AddEmptyOption (boolean)

 

Adds an empty first option. The text will be blank unless explicity set using the EmptyOptionText property.

 

 

...

@(new DbNetComboCore("northwind", "customers", "customerid", "companyname", "filteredcustomers") { AddEmptyOption = true }.Render())

...

 

 

AddFilter (boolean)

 

Adds an input box above the combo that can be used to filter the options

 

...

@(new DbNetComboCore("northwind", "customers", "customerid", "companyname", "filteredcustomers") { AddFilter = true }.Render())

...

 

Demo

 

 

DatabaseType(enum)

DbNetComboCore can be used with a number of databases and in the case of MS SQL Server and SQLite you can normally rely on the control automatically recognising the database type from the connection string. For other database vendors we recommend specifying the database type explicitly either as a property or in the constructor.


...

DbNetComboCore customersCombo = new DbNetComboCore("sakila", "customers", "id", "company") {

  DatabaseType = DatabaseType.MySQL

};

@customersCombo.Render()

...

 

 

DataOnlyColums (List<string>)

 

Specifies additional columns whose values will be accessible as data attributes on the combo box options.

 

...

DbNetComboCore employeesCombo = new DbNetComboCore("northwind", "employees", "employeeid", "lastname || ', ' || firstname", "employeeCombo");

employeesCombo.DataOnlyColumns = new List<string>() { "Title", "TitleOfCourtesy", "BirthDate", "HireDate", "Address", "City", "Region", "PostalCode", "Country", "HomePhone", "Extension" };

employeesCombo.Bind(DbNetComboEventType.OnOptionSelected, "showSelectedCustomer");

@employeesCombo.Render()

...

<script type="text/javascript" class="source">

    function showSelectedCustomer(control, args) {

        var columns = ["Title", "TitleOfCourtesy", "BirthDate", "HireDate", "Address", "City", "Region", "PostalCode", "Country", "HomePhone", "Extension"]

 

        for (var i = 0; i < columns.length; i++) {

            var colName = columns[i];

            var $option = $(args.selectedOptions[0]);

            $(`#${colName}`).text($option.data(colName.toLowerCase()));

        }

    }

</script>

...

 

Demo

 

Distinct (boolean)

 

Setting the Distinct property to true will cause only distinct (unique) values to be selected from the table or view. This can be useful when you want to filter a larger dataset with duplicate values.

 

...

DbNetComboCore customerCombo = new DbNetComboCore("northwind", "customers", "companyname", null, "customer")

{

    ForeignKeyColumn = "city",

    Size = 5,

    AutoRowSelect = true,

    DataOnlyColumns = new List<string>() { "ContactName", "ContactTitle", "Address", "City", "Region", "PostalCode", "Country", "Phone", "Fax" },

};

customerCombo.Bind(EventType.OnOptionSelected, "showSelectedCustomer");

DbNetComboCore cityCombo = new DbNetComboCore("northwind", "customers", "city", null, "city")

{

    ForeignKeyColumn = "country",

    Size = 5,

    Distinct = true,

    AutoRowSelect = true

};

DbNetComboCore countryCombo = new DbNetComboCore("northwind", "customers", "country", null, "country")

{

    Size = 10,

    Distinct = true,

    AutoRowSelect = true

};

cityCombo.AddLinkedControl(customerCombo);

countryCombo.AddLinkedControl(cityCombo);

@countryCombo.Render()

...

 

Demo

 

 EmptyOptionText (string)

 

Specifies the text of the empty option.

 

...

DbNetComboCore tracksCombo = new DbNetComboCore("chinook", "tracks", "trackid", "name", "tracks") { ForeignKeyColumn = "albumid", EmptyOptionText = "Please select a track ..." };

...

 

Demo

 

ForeignKeyColumn (string)

 

Specifies the name of the foreign key column for a child linked combo box. Options will be selected where the value in the foreign key column matches the value of the selected option in the parent combo box.

 

...

DbNetComboCore tracksCombo = new DbNetComboCore("chinook", "tracks", "trackid", "name", "tracks") { ForeignKeyColumn = "albumid", EmptyOptionText = "Please select a track ..." };

DbNetComboCore albumsCombo = new DbNetComboCore("chinook", "albums", "albumid", "title", "albums") { ForeignKeyColumn = "artistid", EmptyOptionText = "Please select an album ..." };

DbNetComboCore artistsCombo = new DbNetComboCore("chinook", "artists", "artistid", "name", "artists") { EmptyOptionText = "Please select an artist ..." };

albumsCombo.AddLinkedControl(tracksCombo);

artistsCombo.AddLinkedControl(albumsCombo);

@artistsCombo.Render()

...

 

Demo

 

MultipleSelect (string)

 

Where the Size property is greater than one, setting this property to true will allow more than one option to be selected.

 

...

DbNetComboCore regionsCombo = new DbNetComboCore("northwind", "regions", "regionid", "regiondescription", "regions") { Size = 10, MultipleSelect = true, AutoRowSelect = true };

...

 

Demo

 

ProcedureParams (Dictionary<string,object>)

 

Supplies any parameter values where the data source is specified as a stored procedure.

 

...

DbNetComboCore inactiveCustomers = new DbNetComboCore("sakila", "GetAllCustomers", "customer_id", "email", null, DataSourceType.StoredProcedure);

inactiveCustomers.ProcedureParams["isActive"] = 0;

inactiveCustomers.Size = 20;

@inactiveCustomers.Render()

...

 

Size (integer)

 

Defines the numer of options visible. The default is one.

...

DbNetComboCore regionsCombo = new DbNetComboCore("northwind", "regions", "regionid", "regiondescription", "regions") { Size = 10, MultipleSelect = true, AutoRowSelect = true };

...

 

Demo

 

 

 

 

 

Copyright © 2023 DbNetLink