<%@ Page language="c#"%>
<!-----------------------------------------------------------------------------------------------------------------
Example of TreeGrid using synchronous (submit, non AJAX) communication with server
Example of tree table
Uses DataTable for database communication
Uses new ASP.NET style scripting with event Page_Load
Uses MS Access database TreeData.mdb as data and XML file TreeDef.xml as TreeGrid layout
! Check if ASP application has write access to TreeData.mdb file 
------------------------------------------------------------------------------------------------------------------>

<!--#include file="TreeGridFramework.aspx"-->

<html>
   <head>
      <link id="GridCSS" href="../../Grid/Grid.css" title="GridStyle" type="text/css" rel="stylesheet">
      <script src="../../Grid/GridE.js"> </script>
   </head>
   <body>
      <div style="WIDTH:100%;HEIGHT:90%">
         <bdo 
            Layout_Url="TreeDef.xml" 
            Data_Tag="TGData" 
            Upload_Tag="TGData" Upload_Format="Internal"
            Export_Url="Export.aspx" Export_Data="TGData" Export_Param_File="SubmitTree.xls"
            ></bdo>
      </div>
      <form method="post" runat="server">
         <input id="TGData" type="hidden" runat="server"/>
         <input type="submit" value="Submit changes to server"/>
      </form>

   </body>
</html>
<script language="c#" runat="server">
// -------------------------------------------------------------------------------------------------------------------------------
// Main event handler, called before rendering, uses TreeGrid class from Main.aspx file
void Page_Load(object sender, System.EventArgs e) {
   TreeGrid Grid = new TreeGrid(
      "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source=\"" + GetPath() + "\\Database.mdb\";Mode=Share Deny None;Jet OLEDB:Engine Type=5;Provider=\"Microsoft.Jet.OLEDB.4.0\";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1",
      "SELECT * FROM TreeData",     // SQL Selection command to select all rows from database, used also for saving data back
      "id",                         //Column name in database table where are stored unique row ids  
      "",                           //Prefix added in front of id, used if ids are number type
      "Parent",                     //Column name in database table where are stored parent row ids, if is empty, the grid does not contain tree
      "Def");                       //Column name in database table where are stored Def parameters (predefined values in Layout, used usually in tree
   if (IsPostBack) Grid.SaveXMLToDB(TGData.Value);  // Saves data to database
   TGData.Value = Grid.LoadXMLFromDB();             // Loads data from database  
}
// -------------------------------------------------------------------------------------------------------------------------------
</script>
