In these examples the aspx page is placed in the application root and the css and gfx files of the grid are placed in sub directories directly below the root. There should be a link to the stylesheet in the Html Head section of the page. You might need to set the ImageDir property if the default value does not suite the directory structure of your ASP.NET application. See Using the Skin files for detailed information.
When using a database query as the data source for the grid, the two properties ConnectionString and one or more of the SQL Commands must be set.
<%@ Page Language="vb" AutoEventWireup="false"%>
<%@ Register TagPrefix="axp" Namespace="Axezz.WebControls" Assembly="AxpDBNet" %>
<html>
<head>
<link href="css/AxpStyleWindowsGrid.css" rel="stylesheet" >
</head>
<body>
<form id="Form1" method="post" runat="server">
<axp:axpdatagrid Runat="Server" ID="AxpDataGrid1"
ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Access\NWind.mdb"
SQL="Select * From Products"
ImageDir="gfx/"></axp:axpdatagrid>
</form>
</body>
</html>
To enable database table editing, a few required properties must be set.
The EditOptions property controls what type of editing should be allowed. The editing options are:
EditPrimaryKeys must be set to the primary key column name.
If a combined primary key is in use, set EditPrimaryKeys to a comma separated list containing the column names. The order of which the column names is specified in the EditPrimaryKeys property must correspond to the Physical Order or to the order they are selected in the SQL (or EditSQL) query.
The database table must in all cases have a Primary Key.
If the primary key is an autogenerated value, the property EditNewPKStatement must be set.
Autogenerated column values in Sql Server is typically an IDENTITY value, in Access it is called "autoincrement" and for Oracle, this is normally a SEQUENCE.
For Sql Server IDENTITY and Access autoincremented primary keys, set EditNewPKStatement="autoincrement"
For Oracle SEQUENCES, a SQL command must be set. F.ex. if the SEQUENCE is named SEQ_TEST, then set AxpDataGrid1.EditNewPKStatement = "SELECT SEQ_TEST.NextVal FROM DUAL"
In the sample below, a few other non-required properties are set. RowClickAction="openform" enables the user to click anywhere in a Grid row to go to the Form, RowRolloverEffect=True adds a rollover effect when the user moves the mouse across the rows, and DisplayNavBar="both" ensures that the Record navigation bar is displayed at the top and bottom of the grid.
<axp:axpdatagrid Runat="Server" ID="AxpDataGrid1" ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Access\NWind.mdb" EditOptions="ALL" SQL="Select * From Products" DeleteSQL="Delete From Products" EditNewPKStatement="autoincrement" EditPrimaryKeys="ProductId" DisplayNavBar="both" ImageDir="gfx/" RowClickAction="openform" RowRollOverEffect="True"></axp:axpdatagrid>