Components of Px Framework:
PxComboBox - component for selecting data from a list, similar to the DropDownList component
The PxComboBox component works similarly to or has got similar properties as the PxEdit
component. Therefore there is no need in their detailed description, for the details please refer to
the previous chapter about the PxEdit component. Things that have been described in detail in case
of the PxEdit component shall only be mentioned here.
The PxComboBox component enables automatic editing of the table row column, which is loaded
in the PxWebQuery component. Create the AddAdresar.aspx file, and type the following definition
of the PxComboBox component there:
AddAdresar.aspx file:
<Prx:PxComboBox ID="cmbPravnaForma" runat="server" AddTableRow="True"></Prx:PxComboBox>
In the AddAdresar.aspx.cs file, define linking of the PxComboBox component to the
PxWebQuery component and its linking to the specific table column.
AddAdresar.aspx.cs file:
protected void Page_Load(object sender, EventArgs e)
{
cmbPravnaForma.PxDataSource = wquAdresar;
cmbPravnaForma.FieldName = "idpravnaforma";
}
The PxComboBox supports automatic loading of the list to its body, and automatic saving of the
selected value to the database, during execution of the Post() command at the PxWebQuery
component.
For automatic loading of the data to the PxComboBox component list, it is necessary to apply the
AddParamKey parameter or the AddParamWebQuery parameter to the PxWebQuery component, to
which the PxComboBox component is linked.
The AddParamKey serves for linking the table to the classifier. The AddParamKey method is the
PxWebQuery component method. According to the Px Framework philosophy as much information
as possible is to be defined on the PxWebQuery component. This actually saves the programming
and writing in case of the PxSuperGrid, PxEdit, PxComboBox and other components. All these
components borrow data and settings from the PxWebQuery component. Therefore, the
PxWebQuery component has a number of procedures and methods, which are used for defining
various display methods and relations between the tables.
So the
AddParamKey method is the simplest method for defining the relation between the main
table and the classifier.
This definition can be written to the
Adresar.aspx.cs file.
protected void Page_Load(object sender, EventArgs e)
{
if ((!IsPostBack)&&(wquAdresar.Active==false))
{
string sSQLText1 = "select IDPravForm as Key, Name as Value from PravForm Order By Value";
wquAdresar.ConnectString = "User Id=skodapeter;Password=aa;Data Source=xe;";
wquAdresar.SQLSelect = "select idadresar,name,address,idpravnaforma,create_date from Adresar";
wquAdresar.AddParamKey("idpravnaforma", "Key", "Value", "Value", "Key", sSQLText1);
wquAdresar.Open();
wquAdresar.Columns["idadresar"].Caption = "ID";
wquAdresar.Columns["name"].Caption = "Meno Osoby";
wquAdresar.Columns["idpravnaforma"].Caption = "Právna Forma";
wquAdresar.Columns["address"].Caption = "Adresa";
wquAdresar.Columns["create_date"].Caption = "Dátum založenia";
}
else
{
}
grdAdresar.PxDataSource = wquAdresar;
grdAdresar.DataBind();
}
Description of the parameters of the AddParamKey method:
C# syntax:
public void AddParamKey(string aFieldName, string aFieldNameKey,
string aFieldNameValue, string aFieldToView,
string aFieldToDB, string aSQLText);
Description of the parameters:
aFieldName - name of the column in the table to which the AddParamKey method is applied
aFieldNameKey - name of the classifier's column, which represents the classifier's key (the name of the
column can be obtained from the SQL command, which is entered to the aSQLText parameter)
aFieldNameValue - name of the classifier's column, which represents the classifier's value (the name of the
column can be obtained from the SQL command, which is entered to the aSQLText parameter)
aFieldToView - is used to enter the name of the column which value shall be displayed in the Grid (PxSuperGrid)
aFieldToDB - is used to enter the name of the column which value shall be put to the database
aSQLText - is used to define the SQL command for loading the classifier, individual columns are to be
appropriately named as Key and Value, for better clarity
After applying the AddParamKey parameter to the PxWebQuery component and linking the
PxComboBox component, this component shall automatically download data during the loading
process and automatically save the selected value to the database during the saving process.
The AddTableRow, TableBegin and TableEnd properties, which are described in detail in the
section dealing with the PxEdit component, are used once again for the alignment of the
component.
Caption name or titles of the columns in the Grid can be defined centrally, during the definition of
the PxWebQuery component, where the value in square brackets is the name of the column:
wquAdresar.Columns["NAME"].Caption = "Persons Name";
Changing the PxComboBox (Label) caption:
Besides central definition, the PxComboBox component caption can be changed in the following
way:
cmbPravnaForma.Caption = "Juridical form";
Here is a functional example of the PxComboBox component, even with source code.
This functional example on this site runs on MySQL 5.0 database.
Others articles of Px Framework:
- PxWebQuery - component for working with databases
- PxSuperGrid - component for the direct display of data in the table
- PxEdit - component for data editing, similar to the TextBox component
- PxComboBox - component for selecting data from a list, similar to the DropDownList component
- PxCheckBox - component for checking the value (Check / UnCheck value)
- PxFlyComboBox - set of the consecutively linked comboboxes, suitable for the work with structured data (for example: selection of category and subcategory)
- PxGreatRepeater - component for entering data with repeating structure, maximum number of values is limited
- PxJSDatePicker - component for the date entry, based on the JavaScript
- PxDbNavigator - the component for the work with the PxWebQuery components, row cursor movement, etc.
- PxLabel - component for data display
- PxCheckBoxList - component to view and select values from the list
- PxRadioButtonList - component for view and selection of a value from the list
- PxChart - the component for displaying and working with charts
- PxFilterView - visual component for filtering the table data contents in the PxWebQuery component
- PxUploader - component for uploading binary and text files to the server
- PxLogin - component for authorization and logging into the application
- Data loading from the Oracle, MSSQL, MySQL, FireBird, Interbase database by means of the PxWebQuery components
- Program inserting, editing or deleting of row into the database by means of the PxWebQuery component
- Loading values from the PxWebQuery component via the while cycle
- Row search in the PxWebQuery component according to the value entered and the name of the column where the search shall be carried out
- The "ReOpen" procedure of the PxWebQuery component and data re-load into the PxWebQuery component
- Validation, checking of the entered values by means of the PxWebQuery component and other visual components (PxEdit, PxComboBox, etc.)
- Events of the PxWebQuery component
- A special function GetValueFromStructKey of the PxWebQuery component
- Setting the language mutation of the Px Framework
- Finding the current version of the Px Framework
It doesn't the intention of this part website, describe in detail the work with PxFramework components, a detailed description of the component
available in manual, which can be downloaded here:
Download manual of Px Framework