ASP.NET Tree_DB Tutorial 2 - How to use Fields and different ways to set their properties

Introduction

This tutorial will explain how to utilize Fields property of Tree_DB
as well as various methods such as Add() and SetProperties().

Classification

Fields can be classified as two types: standard field and additional field.
  1. Standard fields are fields used for describing a node.
    Standard fields can be used by passing StandardFields enum:
    
    	StandardFields.ID
    	StandardFields.ParentID
    	StandardFields.HTMLValue
    	StandardFields.Icon
    	StandardFields.Level
    	StandardFields.Expanded
    	StandardFields.NodePosition
    

  2. Example:
    oTreeDB.Fields[TreeDB.StandardFields.ID].Value = id;
    oTreeDB.Fields[TreeDB.StandardFields.HTMLValue].Value = text;
    
  3. Additional fields are fields containing additional data attached into a node.
    Those additional fields can be added to Fields collection by calling Add() method:
    
    	Add(string FieldName, string FieldType)
    	Add(string FieldName, string Type, string Data)
    

    Example:
    // add additional field
    oTreeDB.Fields.Add("Name", "text");
    oTreeDB.Fields.Add("Age", "numeric", "26");
    
    // change value of additional field
    oTreeDB.Fields["Name"].Value = "Peter";
    oTreeDB.Fields["Age"].Value = "21";
    

Field item attributes

Field item contains following attributes:
Attribute Type Description
DbFieldName string Declare database field name
DbFieldType string Declare database field type
Value string Value of this field
Ignore bool Ignore this field for event execution

Example:
// default fields
oTreeDB.Fields[TreeDB.StandardFields.Icon].Value = "folder.gif";
oTreeDB.Fields[TreeDB.StandardFields.Expanded].Value = "0";

// additional fields
oTreeDB.Fields["Address"].Value = address;


Field item methods

Method Description
void SetProperties(string dbFieldName, string dbFieldType) Set DbFieldName and DbFieldType property of this field

Example:
// SetProperties method
oTreeDB.Fields["Age"].SetProperties("col_Age", "numeric");

Field collection methods

Method Description
void Add(string FieldName, string FieldType) Add additional data field
void Add(string FieldName, string FieldType, string Data) Add additional data field

Example:
// Add method
oTreeDB.Fields.Add("Address", "text");
oTreeDB.Fields.Add("Age", "numeric", "26");