Navigation: DbNetFileCore >

Constructors

 

 

 

 

DbNetFileCore is a server-side ASP.NET Core file system component designed to be used in a Razor view.

 

DbNetFileCore(string folder, string id = null)

 

The constructor has 1 mandatory properties which should be passed to the constructor which is the virtual path to the root of the section of file system to be browsed.

 

...

@(new DbNetFileCore("/documents/invoices").Render())

...

 

Demo

 

It also has a 3rd optional parameter:

 

Id  Specifies the Id of an existing element on the page that want the control to be rendered inside of 

 

Constructor when rendering in an exisiting HTML element

 

...

<div class="source">

    <div class="row">

        <div class="col">

            <h5>Customers</h5>

            <div id="customersEdit"></div>

        </div>

    </div>

    <div class="row">

        <div class="col">

            <h5>Orders</h5>

            <div id="ordersEdit"></div>

        </div>

    </div>

    <div class="row">

        <div class="col">

            <h5>Order Details</h5>

            <div id="orderDetailsEdit"></div>

        </div>

    </div>

</div>

...

 

Note the 3rd parameter specifies the Id of the HTML element inside of which the grid will be rendered

 

...

DbNetEditCore orderDetailsEdit = new DbNetEditCore("northwind", "[order details]", "orderDetailsEdit");

orderDetailsEdit.Column("OrderID").ForeignKey().Hidden();

orderDetailsEdit.Column("ProductID").Lookup(new Lookup("Products", "ProductId", "ProductName")).Label("Product");

orderDetailsEdit.Column("UnitPrice").Format("c");

orderDetailsEdit.LayoutColumns = 3;

 

DbNetEditCore ordersEdit = new DbNetEditCore("northwind", "orders", "ordersEdit");

ordersEdit.Column("CustomerID").ForeignKey().Hidden();

ordersEdit.Column("EmployeeID").Lookup(new Lookup("Employees", "EmployeeId", "lastname + ',' + firstname")).Label("Employee");

ordersEdit.Column("ShipVia").Lookup(new Lookup("Suppliers", "SupplierId", "CompanyName"));

ordersEdit.Column("Freight").Format("c");

ordersEdit.LayoutColumns = 3;

ordersEdit.AddLinkedControl(orderDetailsEdit);

 

DbNetEditCore customersEdit = new DbNetEditCore("northwind", "customers", "customersEdit");

 

customersEdit.Column("CustomerID").Hidden();

customersEdit.AddLinkedControl(ordersEdit);

customersEdit.LayoutColumns = 3;

 

@customersEdit.Render()

...

 

Demo

 

Specifying the database type in the constructor

 

If you are using a database other than MS SQL Server or SQLite which have their Data Providers included in the .Net Framework then you will need to install the required Data Provider for the database you are connecting to and to also specify the type of database in the constructor

 

...

DbNetEditCore customersEdit = new DbNetEditCore("sakila", DatabaseType.MySQL, "customers");

customersEdit.Column(new string[] { "company", "last_name", "first_name" }).Browse();

@customersEdit.Render()

...

 

 

 

Copyright © 2023 DbNetLink