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:


PxCheckBox - component for checking the value (Check / UnCheck value)



The PxCheckBox 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 chapter about the PxEdit component. Things that have been described in detail in case of the PxEdit component shall only be mentioned here.

The PxCheckBox 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 PxCheckBox component there:

AddAdresar.aspx file::

<Prx:PxCheckBox ID="chkInvalid_Adress" runat="server" AddTableRow="True"></Prx:PxCheckBox>

In the AddAdresar.aspx.cs file, define linking of the PxCheckBox 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)
{
  chkInvalid_Adress.PxDataSource = wquAdresar;
  chkInvalid_Adress.FieldName = "Invalid_Adress";
}

The PxCheckBox component supports automatic loading of value from the PxWebQuery component and automatic saving of the entered value to the database, while executing the Post() command at the PxWebQuery component. Thus, as the PxCheckBox component allows to select only two states, i.e. True or False, it is possible to specify at the PxWebQuery component, the way these states shall be displayed and saved to the database. The parameter with the AddParamCheck parameter method is used for such definition. The AddParamCheck method is the PxWebQuery component method.

Description of the parameters of the AddParamCheck method:

C# syntax:

public void AddParamCheck(string aFieldName,
        string aCheckedValue, string aUnCheckedValue,
        bool aEditReadOnly)


Description of the parameters:

aFieldName - name of the column in the table to which the AddParamCheck method is applied
aCheckedValue - String value that shall replace the "True" value, during selection in the PxCheckBox component
aUnCheckedValue - String value that shall replace the "False" value, during selection in the PxCheckBox component
aEditReadOnly - If the grid is in the "edit" state and the value entered is "True" the editing operation shall be allowed

After applying the AddParamCheck parameter to the PxWebQuery component and linking the PxCheckBox component, this component can automatically interpret data loaded from the database during the loading process and automatically save the defined string value to the database during the saving process.

In this, the definition of the AddParamCheck parameter shall be as follows:

wquAdresar.AddParamCheck("invalid_adress", "A", "N", false);

This definition can be written to the Adresar.aspx.cs file, and it shall be as follows:

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,invalid_adress
                            from Adresar02";
    wquAdresar.AddParamKey("idpravnaforma", "Key", "Value", "Value", "Key", sSQLText1);
    wquAdresar.AddParamCheck("invalid_adress", "A", "N", false);
    wquAdresar.Open();
    wquAdresar.Columns["idadresar"].Caption = "ID";
    wquAdresar.Columns["name"].Caption = "Persons Name";
    wquAdresar.Columns["idpravnaforma"].Caption = "Juridical form";
    wquAdresar.Columns["address"].Caption = "Address";
    wquAdresar.Columns["create_date"].Caption = "Date of Establishment";
    wquAdresar.Columns["invalid_adress"].Caption = "Invalid address";
  }
  else
  {
  }
  grdAdresar.PxDataSource = wquAdresar;
  grdAdresar.DataBind();
}

After entering or applying of AddParamCheck parameter to the PxWebQuery component, the PxSuperGride component shall display values , instead of the "True" value the "A" value shall be displayed and instead of the "False" value the "N" value shall be displayed. Entry to the database shall be carried out in the similar way.

For more details please refer to the image below:

Picture form of the Grid - AddParamCheck


The AddAdresar.aspx form shall look like as follows:

Picture form of PxCheckBox - AddParamCheck


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["invalid_adress"].Caption = "Invalid address";

Changing the PxCheckBox (Label) caption:
Besides central definition, the PxCheckBox component caption can be changed in the following way:

chkInvalid_Adress.Text = "Invalid address 2";



Here is a functional example of the PxCheckBox 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.6. 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