Category form has table layout, similar to the layout of the ASP.NET DetailsView
server control. The table was auto generated in design time and then our web designer
has added styles and a header.
This sample demonstrates how to extract the auto-increment id of newly inserted
values. After a new record is inserted its id is displayed in a message.
The Picture column is of type 'image' which is represented as byte[] in ADO.NET.
A FileUpload server control is automatically generated for this column when the
form is displayed in edit mode.
The
Description column is of type ntext, which means that its values are not limited
in size. In this demo HTMLEditorTemplate is used and the text is edited with the built-in HTML Editor.
Default values for Insert mode are also demonstrated. The CategoriesDataSource SmartDataSource
has three input parameters for the insert operation. The Description parameter has
been given a default value. When the form is displayed in Insert mode the Description
text field is prefilled with this default value.
In this example paging buttons are used for changing the currently selected record.
The event handlers for this buttons have been easily implemented to invoke the navigation
methods provided by SmartDBView. When the Next button is pressed the SetNextRowIndex
method is called. This method takes care of incrementing the RowIndex and rebinding
the form.
This form also uses the query parameter “CategoryID” which determines the currently
displayed record. This mechanism is used by the Products form to open the details
of the category of the displayed product.
When CategoryID query parameter is specified, the paging buttons are hidden. The
Insert and Delete buttons are also hidden during databinding.
CREATE TABLE [dbo].[Categories](
[CategoryID] [int] IDENTITY(1,1) NOT NULL,
[CategoryName] [nvarchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Description] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Picture] [image] NULL,
CONSTRAINT [PK_Categories] PRIMARY KEY CLUSTERED
(
[CategoryID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]