|
Server API Reference |
Top Previous Next |
|
As an alternative to the implementation of DbNetEdit as a client-object it can also be implemented as a server-control which has the advantage of offering intellisense support in Visual Studio. The server-control acts a wrapper for the client-control and generates the required JavaScript to implement the control. <%@ Register TagPrefix="DNL" Namespace="DbNetLink.DbNetSuite.UI" Assembly="DbNetLink.DbNetSuite" %> ... <DNL:DbNetEdit id="dbnetedit1" runat="server" ConnectionString = "SamplesDatabase" FromPart = "Products" > <EditColumns> <DNL:EditColumn ColumnExpression="ProductName" Required="true"/> <DNL:EditColumn ColumnExpression="SupplierID" Lookup="select SupplierID, CompanyName from suppliers"/> <DNL:EditColumn ColumnExpression="UnitPrice" Required="true"/> </EditColumns> <EditClientEvents> <DNL:EditClientEvent EventName="onRecordValidate" Handler="validateInsert"/> </EditClientEvents> </DNL:DbNetEdit> The simplest edit control can be created by specifying just the ConnectionString and FromPart properties The ConnectionString property provides the information necessary to connect to the database. The connection string can either be an actual connection string or an alias which is resolved by finding a matching entry in the <connectionStrings> section of the web.config file. For details of specifying connection strings see the database connectivity section. The FromPart property specifies the name of the table against which the form will be applied.
<DNL:DbNetEdit
id="DbNetEdit1"
runat="server"
ConnectionString="SamplesDatabase"
FromPart="customers">
</DNL:DbNetEdit>
The EditColumns collection allows you to specify the columns that you require from the table specified in the FromPart property. DbNetEdit willl generate an edit control for each column specified. See Edit Column Properties for details of edit column properties.
<DNL:DbNetEdit
ID="DbNetGrid1"
runat="server"
ConnectionString="SamplesDatabase"
FromPart="Products">
<EditColumns>
<DNL:EditColumn ColumnExpression="ProductID" />
<DNL:EditColumn ColumnExpression="ProductName" />
<DNL:EditColumn ColumnExpression="CategoryId" />
</EditColumns>
</DNL:DbNetEdit>
If you want to have control over the layout of the form and the placement of the edit fields you can use the FormTemplate control to define an HTML template that use <span> elements to define placeholders for the editable fields in the template. The <span> elements must define the attribute columnExpression with the name of the table column. Additional properties can also be defined as attributes of the <span> element. <DNL:DbNetEdit id="dbnetedit1" runat="server" ConnectionString = "SamplesDatabase" FromPart = "Employees" > <FormTemplate> <table id="dbnetedit1"> <tr> <td> <table> <tr> <td style="vertical-align:top"> <fieldset> <legend>Personal Details</legend> <table> <tr> <td>Employee ID</td> <td><span ColumnExpression="EmployeeID" /></td> </tr> <tr> <td>Last Name</td> <td><span ColumnExpression="LastName" Style="width:100px" /></td> </tr> <tr> <td>First Name</td> <td><span ColumnExpression="FirstName" /></td> </tr> <tr> <td>Title</td> <td><span Style="width:100px" ColumnExpression="TitleOfCourtesy"/></td> </tr> </table> </fieldset> </td> <td style="vertical-align:top"> <fieldset> <legend>Employment Details</legend> <table> <tr> <td>Birth Date</td> <td><span ColumnExpression="BirthDate" Required="true"/></td> </tr> <tr> <td>Hire Date</td> <td><span ColumnExpression="HireDate"/></td> </tr> <tr> <td>Reports To</td> <td><span ColumnExpression="ReportsTo" Lookup="select EmployeeID, LastName + ' ' + FirstName from Employees"/></td> </tr> </table> </fieldset> </td> <td style="vertical-align:top"> <fieldset> <legend>Address</legend> <table> <tr> <td>Address</td> <td><span Style="width:220px;height:30px;" EditControlType="TextArea" ColumnExpression="Address" /></td> </tr> <tr> <td>City</td> <td> <table cellpadding="0" cellspacing="0"> <tr> <td><span ColumnExpression="City" /></td> <td>Region</td> <td><span Style="width:50px" ColumnExpression="Region" /></td> </tr> </table> </td> </tr> <tr> <td>Country</td> <td><span ColumnExpression="Country"/></td> </tr> <tr> <td>Phone</td> <td> <table cellpadding="0" cellspacing="0"> <tr> <td><span ColumnExpression="HomePhone" Style="width:140px"/></td> <td>Ext</td> <td><span ColumnExpression="Extension"/></td> </tr> </table> </td> </tr> </table> </fieldset> </td> </tr> </table> </td> </tr> <tr> <td> <table> <tr> <td style="vertical-align:top"> <fieldset> <legend>Notes</legend> <span ColumnExpression="Notes" Style="width:400px;height:60px" EditControlType="Html"></span> </fieldset> </td> <td style="vertical-align:top"> <fieldset> <legend>Photo</legend> <span UploadExtFilter="png,jpg,gif" ColumnExpression="Photo" MaxThumbnailHeight="120"></span> </fieldset> </td> </tr> </table> </td> </tr> <tr> <td style="text-align:right;border-top:1pt solid silver" ID="dbnetedit1_toolbarPanel"></td> </tr> <tr> <td ID="dbnetedit1_messagePanel"></td> </tr> </table> </FormTemplate> </DNL:DbNetEdit> Enables/disables the advanced search dialog Enables tracking of the date and the user that changes made to the record. Possible values are None, Summary and Detail. In Summary mode only the date/user of the last change to a record is recorded, in Detail mode all changes to the record are recorded and can be viewed in the Audit History dialog.
Auditing can also be implemented at the column level if changes to a specific column need to be tracked. Controls the format of the last modified date displayed when auditing is enabled. Identifies the user that made a change when auditing is enabled. If the web application page is authenticated then the property will default to the authenticated user. Specifies the height of the browse dialog Specifies the width of the browse dialog Specifies the number of seconds the grid population query should run before timing out. The default is 30 seconds. A value of 0 will prevent the query from timing out at all. <DNL:DbNetEdit ... CommandTimeout="120"> </DNL:DbNetEdit> User profiles can also save information other than edit properties by assigning the CustomProfileProperties property with either the name of a window property or a jQuery id or class selector that matches an input, select or textarea element as a comma separated list. The values in these elements/variables will be saved and restored with the profile Instance of DbNetSpell server control to be configured when adding spell checking to the edit dialog <DNL:DbNetEdit id="customersEdit" runat="server" ConnectionString = "SamplesDatabase" FromPart = "customers" SpellCheck = "true" > <DbNetSpell ConnectionString="DictionaryDatabase" DictionaryTableName="english_us" > </DbNetSpell> </DNL:DbNetEdit> The EditClientEvents collection allows you to specify handlers for any of the client-side events that are available. <DNL:DbNetEdit id="dbnetedit1" runat="server" ConnectionString = "SamplesDatabase" FromPart = "Products" > <EditColumns> <DNL:EditColumn ColumnExpression="ProductName" Required="true"/> <DNL:EditColumn ColumnExpression="SupplierID" Lookup="select SupplierID, CompanyName from suppliers"/> <DNL:EditColumn ColumnExpression="UnitPrice" Required="true"/> </EditColumns> <EditClientEvents> <DNL:EditClientEvent EventName="onRecordValidate" Handler="validateInsert"/> </EditClientEvents> </DNL:DbNetEdit> Specifies a filter to applied to the selected edit records. Sql can include parameter placeholders with values supplied using the FixedFilterParams collection <DNL:DbNetEdit id="customersGrid" runat="server" ConnectionString = "SamplesDatabase" FromPart = "Customers" FixedFilterSql="country = ?" > <EditColumns> <DNL:GridColumn ColumnExpression="CustomerID" Label="CompanyName" Required="true"/> <DNL:GridColumn ColumnExpression="CompanyName" Label="CompanyName" Required="true"/> <DNL:GridColumn ColumnExpression="ContactName"/> <DNL:GridColumn ColumnExpression="ContactTitle"/> </EditColumns> <FixedFilterParams> <DNL:Parameter Name="country" Value="USA"/> </FixedFilterParams> </DNL:DbNetEdit>
Collection of Parameter elements used in combination with the FixedFilterSql parameter to supply parameter values. If set to true the edit form will automatically enter insert mode when initialized and remain so after a record is inserted. Defines the number of columns over which the generated DbNetEdit layout is distributed (defaults to 1)
The LinkedControls collection specifies any child DbNetGrid or DbNetEdit controls. The LinkedControl element has 2 properties. LinkedControlID specified the ID of the child control and OneToOne which indicates if the parent child relationship is one-to-one or one-to-many.The relationship between the parent and child control is created by using the PrimaryKey of the parent grid to query the ForeignKey of the child control. <DNL:DbNetEdit id="CustomersEdit" runat="server" ConnectionString = "SamplesDatabase" FromPart = "Customers" > <EditColumns> <DNL:EditColumn ColumnExpression="CustomerID" Display="false"/> <DNL:EditColumn ColumnExpression="CompanyName"/> <DNL:EditColumn ColumnExpression="Address"/> <DNL:EditColumn ColumnExpression="City"/> </EditColumns> <LinkedControls> <DNL:LinkedControl LinkedControlID="OrdersEdit" OneToOne="false"/> </LinkedControls> </DNL:DbNetEdit> ... <DNL:DbNetEdit id="OrdersEdit" runat="server" ConnectionString = "SamplesDatabase" FromPart = "Orders" > <EditColumns> <DNL:EditColumn ColumnExpression="CustomerID" ForeignKey="true" Display="false"/> <DNL:EditColumn ColumnExpression="OrderID"/> <DNL:EditColumn ColumnExpression="OrderDate" Format="D" ToolTip="Date ordered"/> <DNL:EditColumn ColumnExpression="RequiredDate" Format="d" ToolTip="Date required"/> <DNL:EditColumn ColumnExpression="ShippedDate" Format="MMM yyyy" ToolTip="Date shipped"/> <DNL:EditColumn ColumnExpression="Freight" Format="c" ToolTip="Freight charge"/> </EditColumns> <LinkedControls> <DNL:LinkedControl LinkedControlID="OrderLinesEdit" OneToOne="false"/> </LinkedControls> </DNL:DbNetEdit> ... <DNL:DbNetEdit id="OrderLinesEdit" runat="server" ConnectionString = "SamplesDatabase" FromPart = "[Order Details]" > <EditColumns> <DNL:EditColumn ColumnExpression="OrderID" ForeignKey="true"/> <DNL:EditColumn ColumnExpression="ProductID" Lookup="select productid, productname from products" Label="Product" ToolTip="Date ordered"/> <DNL:EditColumn ColumnExpression="UnitPrice" Format="c" ToolTip="Enter the net price (without tax)"/> <DNL:EditColumn ColumnExpression="Quantity" ToolTip="Enter quantity currently in stock"/> <DNL:EditColumn ColumnExpression="Discount" Format="p" ToolTip="Enter discount as a percentage"/> </EditColumns> </DNL:DbNetEdit>
Set the initial order by which rows are returned. <DNL:DbNetEdit ... OrderBy="Country,City"> </DNL:DbNetEdit> Identifies the user against which User Profiles will be saved. If the web application is authenticated then the property will default to the authenticated user. If an application is using a custom authentication method then the property can be set in a manner similar to the following code.
///////////////////////////////////////////////////////////////
protected override void OnLoad(EventArgs e)
///////////////////////////////////////////////////////////////
{
base.OnLoad(e);
customersGrid.ProfileUser = Session["userid"].ToString();
}
Fixes the height of the search dialog when there are a lot of searchable columns. Search fields will scroll inside dialog <DNL:DbNetEdit ... SearchDialogHeight="200px"> </DNL:DbNetEdit> Specifies the default search mode. Can be set to either Simple, Standard or Advanced Specifies the number of columns over which the search criteria are distributed Specifies if only the search values are selectable in the search dialog/panel The SearchPanelId property allows you to specify the Id or Class Name of an HTML element to be used as the container of the search control (instead of the Search Dialog) Enables/disables the simple search dialog Indicates that a spell checking should be enabled for all the text columns longer that 29 characters. To enable spell checking for particular columns use the column SpellCheck property. The DbNetSpell object can be configure via the DbNetSpell property. Enables/disables the standard search dialog The following properties control the buttons and information displayed in the toolbar
Controls the appearance of the Delete record button in the toolbar <DNL:DbNetEdit ... Delete="false"> </DNL:DbNetEdit>
Controls the appearance of the insert new record button in the toolbar <DNL:DbNetEdit ... Insert="false"> </DNL:DbNetEdit>
Controls the appearance of the navigation buttons in the toolbar <DNL:DbNetEdit ... Navigation="false"> </DNL:DbNetEdit>
Controls the appearance of the Page X of Y information in the toolbar <DNL:DbNetEdit ... PageInfo="false"> </DNL:DbNetEdit>
Adds a search box to the toolbar which can be used to search against all the columns that have been flagged as eligible for SimpleSearch <DNL:DbNetEdit ... QuickSearch="true"> </DNL:DbNetEdit>
Controls the appearance of the search dialog button in the toolbar <DNL:DbNetEdit ... Search="false"> </DNL:DbNetEdit>
Enables/disables access to the the Column Sort Selection dialog from the toolbar <DNL:DbNetEdit ... Sort="true"> </DNL:DbNetEdit> Sets the the style of the toolbar button. Choose from Image, Text or ImageAndText Sets the location/visibility of the toolbar. Values are Top (toolbar displayed above grid), Bottom (toolbar displayed below grid) or Hidden (toolbar is hidden)
Controls the User Profile button in the toolbar <DNL:DbNetEdit ... UserProfile="true"> </DNL:DbNetEdit>
Controls the appearance of the User Profile selection list in the toolbar <DNL:DbNetEdit ... UserProfile="true" UserProfileSelect="true" > </DNL:DbNetEdit>
|