Please enable JavaScript to view this site.

Navigation: Using ASPRunner.NET > REST API Connections and Views

Code Views

Scroll Prev Next More

 

You can also create views are based on C#/VB.NET code. For instance, you can display a list of files from the file system. Handy, if you need to implement a file manager for instance. ASPRunner.NET will build the sample code for you and you can extend it any way you need it.

 

To create a Code View create a SQL View first and then click "Switch to C#/VB.NET mode" button. You can switch back to SQL mode if you need to.

 

Here is an example of just supplying some data as an array:

 

 

dynamic data = XVar.Array();
data.InitAndSetArrayItem( new XVar( "id",1,"name","aaa" ),null );
data.InitAndSetArrayItem( new XVar( "id",2,"name","bbb" ),null );
data.InitAndSetArrayItem( new XVar( "id",3,"name","ccc" ),null );dynamic result = new ArrayResult( data );if( !result ) {
dataSource.setError( DB.LastError() );
return false;
}
// filter results, apply search, security & other filters
result = dataSource.filterResult( result,command.filter );
// reorder results as requested
dataSource.reorderResult( command,result );
return result;

 

 

You will also need to define two fields, id (integer) and name (varchar). This is it, you can build your app and all functions like search, filters, pagination will work out of the box. If you ever needed to build pages that are not tied to any database table - your prayers were answered. You can use Code Views, for instance, to build a feedback form where data entered by the user is sent to your email.