en_lang.jpg, 1 kB sk_lang.jpg, 1 kB
English Slovak

      Px Framework - ASP.NET components for rapid development of database applications


Menu:



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.

Image form to PxComboBox


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.

No. Example Name Source Codes SQL Script
1.5. Adresar.aspx
Adresar.aspx.cs
AddAdresar.aspx
AddAdresar.aspx.cs
SQLScript_MySQL.5.1
SQLScript_MySQL.5.0



Others articles of 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