"The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination." - Fred Brooks
Bookmark and Share      
ASP DataGridColumns .NET assembly (for VB.NET, C#, J#)

Obviously, your task is to create a database connection and command that binds data to an ASP .NET DataGrid server control. Also you need provide your users with a friendly interface.

One of the most permanent challenges in designing user interfaces is figuring out how to display large amounts of data efficiently and intuitively without bewildering the user. The problem becomes particularly thorny when the interface must give the ability to easily update and store the data that the user needs to modify.
The ASP .NET DataGrid control gives developers a powerful and flexible tool to meet this challenge. You do not need to look for some third-vendors’ costly datagrids. The ASP .NET DataGrid server control is smart enough.

Download freeware now!

ASPDataGridColumns .NET assembly from RustemSoft is a DataGrid Columns software package specifically designed for ASP .NET developers. The assembly allows you to use all strengths of the .NET DataGrid server control without waiving the user interface elements your customers need.

FREEWARE

The downloadable samples explain ASP .NET DataGrid control basic operations and show how to extend it to display different kinds of data columns in an application-appropriate manner. By using the assembly you can create your own set of DataGrid Columns objects that defines custom columns for the ASP .NET DataGrid server control.

Controls .NET assembly (WinForms)
More about RustemSoft.Controls.dll
Download RustemSoft.Controls.dll
Order RustemSoft.Controls.dll

A column is an object that defines what the column looks and behaves like, including such things as color, font, and the presence of controls that will handle linked field in a database with the use of a Combo Box, a Check Box and other control.
The RustemSoft ASP DataGrid Columns assembly contains a special DataGridCommands class that allows you to manage a DataGrid's datasource. The ASPDataGridColumns dynamic link library contains the following DataGrid Columns:

  • ASP DataGrid Combobox Column
  • ASP DataGrid TextBox Column
  • ASP DataGrid DropDown Column
  • ASP DataGrid DatePicker Column
  • ASP DataGrid CheckBox Column
  • ASP DataGrid DateTime Column
  • ASP DataGrid Numeric Column
  • ASP DataGrid Text Fractions Column
  • ASP DataGrid TextEdit Column
  • ASP DataGrid UpDown Column
  • Let's examine the very basics of ASP .NET DataGrid Columns usage - how to plop the columns down on an ASP.NET Web page and display bound database results.

    DataGridCommands class

    The DataGrid Web control is by far the most versatile and powerful of all ASP .NET controls. RustemSoft ASP DataGrid Columns assembly extends its features. The assembly not only does it have many properties for every DataGrid Column object that you can set programmatically, but it lends itself to more advanced functionalities of customization. The RustemSoft ASP DataGrid Columns assembly contains the special DataGridCommands class that helps you manage a DataGrid's datasource. It allows you to input, update and store data into rows in a currently opened datasource. RustemSoft tried to approximate the Windows Forms DataGrid implementation to ASP .NET DataGrid server control and we got an amazing result. By using UpdateDataSource method of the class you can easily save all updates that your user made in ASP DataGrid interface into bound datasource.
    First a DataGrid has been populated from a datasource. After a user updates a record and save back to datasource. By using the DataGridCommands class interface we can maintain the integrity of back-end data.

    VB .NET
    ' Save datagrid data source tableDataSource table
    Dim DGCommands As DataGridCommands = New DataGridCommands()
    DGCommands.UpdateDataSource(tableDataSource, yourDataGrid)

    C#
    // Save datagrid data source tableDataSource table
    DataGridCommands DGCommands = new DataGridCommands();
    DGCommands.UpdateDataSource(tableDataSource, yourDataGrid);

    Windows Forms DataGridColumns .NET assembly
    More about DataGridColumns.dll
    Download DataGridColumns.dll
    Order DataGridColumns.dll

    By clicking the "Save" button your user will be able to save all updates into DataGrid's datasource data object.

    ASP DataGrid Combobox Column

    The combobox column is not a dropdown list, which appears when a datagrid cell becomes the current cell. The ASP .NET DataGrid combobox Column control has the following attractive features:

    This DataGrid Column gives you ability to instantly update cell value with a really simple and friendly user interface. When you click the special button of the combo a separate designed by you interface Page will be shown over the datagrid. You can implement a dictionary of all combobox possible values on this interface Page.

    When the Interface Page appears it can receive the selected combobox value that can be used on the Interface Page. Also when you close the Interface Page by choosing some item it retrieves into selected datagrid’s combobox cell two parameters: ValueMember’s value and DisplayMember’s value.

    You can set its DataSource, DisplayMember, and ValueMember to bind the combobox to a foreign table.

    By implementing in your code an interface with the DataGridCommands class you will be able to save all updates into DataGrid's datasource data object. By using UpdateDataSource method of the class you can easily save all updates that your user made in ASP DataGrid ComboBox Column into bound datasource.

    Syntax
    <RustemSoft:ComboBoxColumn DataField="Data Field Name" HeaderText="Header Text"/>


    VB .NET
    ' Define comboCompany variable as an object of ComboBoxColumn class
    ' and assign it to the DataGrid1 'Company' column.
    Dim comboCompany As ComboBoxColumn = DataGrid1.Columns(5)
    ' Define Name of Interface Page that will be called by clicking on ComboBox button
    comboCompany.InterfacePageName = "ComboInterfacePage.aspx"

    ' Define width of Interface Page
    comboCompany.InterfacePageWidth = 290
    ' Define height of Interface Page
    comboCompany.InterfacePageHeight = 400
    ' Assign DataSource property for comboCompany object as tblCompanies
    ' data table where Companys’s names are stored.
    comboCompany.DataSource = tblCompanies
    ' Specify DisplayMember as "Name" field of tblCompanies table
    comboCompany.DisplayMember = "Name"
    ' Specify ValueMember as "PubID" field of tblCompanies table
    comboCompany.ValueMember = "PubID"
    ' Identify "Company" column's foreground color
    comboCompany.ForeColor = Color.DarkMagenta
    ' Identify "Company" column characters' font and size
    comboCompany.Font_Name = "Tahoma"
    comboCompany.Font_Size = FontUnit.Point(8)
    ' Adjust "Company" column's width
    comboCompany.Width = Unit.Point(60)

    C#
    // Define comboCompany variable as an object of ComboBoxColumn class
    // and assign it to the DataGrid1 'Company' column.
    ComboBoxColumn comboCompany = (ComboBoxColumn)DataGrid1.Columns[5];

    XML Converter is available!
    More about XML Converter
    Download XML Converter
    Order XML Converter

    // Define Name of Interface Page that will be called by clicking on ComboBox button
    comboCompany.InterfacePageName = "ComboInterfacePage.aspx";
    // Define width of Interface Page
    comboCompany.InterfacePageWidth = 345;
    // Define height of Interface Page
    comboCompany.InterfacePageHeight = 400;
    // Assign DataSource property for comboCompany object as tblCompanies
    // data table where Companys’s names are stored.
    comboCompany.DataSource = tblCompanies;
    // Specify DisplayMember as "Name" field of tblCompanies table
    comboCompany.DisplayMember = "Name";
    // Specify ValueMember as "PubID" field of tblCompanies table
    comboCompany.ValueMember = "PubID";
    // Identify "Company" column's foreground color
    comboCompany.ForeColor = Color.DarkMagenta;
    // Identify "Company" column characters' font and size
    comboCompany.Font_Name = "Tahoma";
    comboCompany.Font_Size = FontUnit.Point(8);
    // Adjust "Company" column's width
    comboCompany.Width = Unit.Point(60);

    How to pass the selected combobox value to Interface Page?

    Let's suppose that you have TextBox1 control on your Interface Page and you need assign its Text value with combobox cell value when the Interface Page will be open. For this case you need to add into your ASP Interface Page the following code:
    <HEAD>
    ...................
    <script id="clientEventHandlersJS" language="javascript">
    function windowLoad() {
    if (window.dialogArguments != null) {
    document.all('TextBox1').value=window.dialogArguments;}
    }
    </script>
    </HEAD>
    <body onload="return windowLoad()">

    How to retrieve values into selected datagrid’s combobox cell?

    You have designed an Interface Page and attached it to your ComboBox Column by using its InterfacePageName property. Now when you close the Interface Page by choosing some item it retrieves into selected datagrid's combobox cell two parameters: ValueMember's value and DisplayMember's value. To accomplish that you need to place into your page code the following procedure:

    VB .NET
    Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand
    ' Return selected value
    Dim DGCommands As DataGridCommands = New DataGridCommands()
    Response.Write(DGCommands.ReturnedValue(e.Item.Cells(0).Text, e.Item.Cells(1).Text))
    End Sub

    C#
    private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    // Return selected value
    DataGridCommands DGCommands = new DataGridCommands();
    Response.Write(DGCommands.ReturnedValue(e.Item.Cells[0].Text, e.Item.Cells[1].Text));
    }


    ASP DataGrid TextBox Column

    The TextBoxColumn hosts a TextBox control that allows users to directly edit text values.

    By default, the TextMode property is set to SingleLine, which creates a text box with only one line. You can also set the property to MultiLine or Password. MultiLine creates a text box with more than one line. Password creates a single-line text boxes in your ASP DataGrid TextBoxColumn that mask the value entered by the user.

    The display width of each cell's text box is determined by its Width property. You can limit the number of characters that can be entered in TextBox of every DataGrid cell by setting the MaxLength property. Set the Wrap property to true to specify that the contents of the cell should automatically continue on the next line when the end of the text box is reached.

    By implementing in your code an interface with the DataGridCommands class you will be able to save all updates into DataGrid's datasource data object. By using UpdateDataSource method of the class you can easily save all updates that your user made in ASP DataGrid TextBox Column into bound datasource.


    Syntax
    <RustemSoft:TextBoxColumn DataField="Data Field Name" HeaderText="Header Text"/>

    VB .NET
    ' Define TxtBox variable as an object of TextBox Column class
    ' and assign it to the DataGrid1 "City" column.
    Dim TxtBox As TextBoxColumn = DataGrid1.Columns(2)
    ' Identify "City" column's foreground color
    TxtBox.ForeColor = Color.DarkMagenta
    ' Identify "City" column characters' font and size
    TxtBox.Font_Name = "Tahoma"
    TxtBox.Font_Size = FontUnit.Point(8)
    ' Adjust "City" column's width
    TxtBox.Width = Unit.Point(60)

    C#
    // Define TxtBox variable as an object of TextBox Column class
    // and assign it to the DataGrid1 "City" column.
    TextBoxColumn TxtBox = (TextBoxColumn)DataGrid1.Columns[2];
    // Identify "City" column's foreground color
    TxtBox.ForeColor = Color.DarkMagenta;
    // Identify "City" column characters' font and size
    TxtBox.Font_Name = "Tahoma";
    TxtBox.Font_Size = FontUnit.Point(8);
    // Adjust "City" column's width
    TxtBox.Width = Unit.Point(60);

    Free XMLFox XML/XSD Editor
    More about XMLFox freeware Editor
    Download XMLFox Editor


    ASP DataGrid DropDown Column

    Use the ASP DataGrid DropDownColumn to create a single selection drop-down list control in each cell of DataGrid column. You can control the appearance of the ASP DataGrid DropDownColumn by setting the BackColor, ForeColor, BorderColor, BorderStyle, and other properties. The control displays in a datagrid cell a single value that is selected from a collection by clicking the button of the control. Your user can enter text in the control if the string typed in matched an item in the collection to be accepted.

    The ASP DataGrid DropDownColumn supports data binding. To bind the control to a data source, create a data source, such as a System.Collections.ArrayList object, that contains the items to display in the column. Then, use the DataSource property to bind the data source to the ASP DataGrid DropDownColumn. You can use a System.Data.DataTable or System.Data.DataRowView or System.Collections.ArrayList object as a datasource for your DropDownColumn. For this kind of a datasource you need to specify ValueMember and DisplayMember properties.

    By implementing in your code an interface with the DataGridCommands class you will be able to save all updates into DataGrid's datasource data object. By using UpdateDataSource method of the class you can easily save all updates that your user made in ASP DataGrid DropDown Column into bound datasource.


    Syntax
    <RustemSoft:DropDownColumn DataField="Data Field Name" HeaderText="Header Text"/>

    The ASP DataGrid DropDown Column class has the following useful properties:

    DataSource - a source for a DataGrid DropDown column values list as System.Data.DataTable or System.Data.DataRowView or System.Collections.ArrayList

    DisplayMember - field to display in a column cell as String (name of a DataTable column)

    ValueMember - field with values, which binds to drop-down control as String (name of table column). Specify the contents of the ValueMember property in cases where you bind data.

    VB .NET
    ' Define DropDown variable as an object of DropDownColumn class
    ' and assign it to the DataGrid1 'State' column.
    Dim DropDown As DropDownColumn = DataGrid1.Columns(5)
    ' Assign DataSource property for DropDown object as tblStates
    ' data table where states’s names are stored.
    DropDown.DataSource = tblStates
    ' Specify DisplayMember as "Name" field of tblStates table
    DropDown.DisplayMember = "Name"
    ' Specify ValueMember as "State" field of tblStates table
    DropDown.ValueMember = "State"
    ' Identify "State" column's foreground color
    DropDown.ForeColor = Color.DarkMagenta
    ' Identify "State" column characters' font and size
    DropDown.Font_Name = "Tahoma"
    DropDown.Font_Size = FontUnit.Point(8)
    ' Adjust 'State' column's width
    DropDown.Width = Unit.Point(60)

    C#
    // Define DropDown variable as an object of DropDownColumn class
    // and assign it to the DataGrid1 'State' column.
    DropDownColumn DropDown = (DropDownColumn)DataGrid1.Columns[5];
    // Assign DataSource property for DropDown object as tblStates
    // data table where states’s names are stored.
    DropDown.DataSource = tblStates;
    // Specify DisplayMember as "Name" field of tblStates table
    DropDown.DisplayMember = "Name";
    // Specify ValueMember as "State" field of tblStates table
    DropDown.ValueMember = "State";
    // Identify "State" column's foreground color
    DropDown.ForeColor = Color.DarkMagenta;
    // Identify "State" column characters' font and size
    DropDown.Font_Name = "Tahoma";
    DropDown.Font_Size = FontUnit.Point(8);
    // Adjust 'State' column's width
    DropDown.Width = Unit.Point(60);


    ASP DataGrid DatePicker Column

    The DatePicker Column is used to allow the user to select a date, and to display that date in your ASP .NET DataGrid interface.

    By clicking the DatePicker Column's button you will get a separated browser Page that displays a stylized calendar. Clicking on your chosen date in Calendar Page the date value will be returned into currently selected DataGrid cell in a Date format that you have defined previously.

    Also the DatePicker Column can be used to allow the user to insert formatted date, and to display that date in your DataGrid without using the pop-up Calendar Form. The DatePicker column provides the entered date validation.

    The ASP DataGrid DatePicker Column class has the following useful properties:

    Format - Various formats may be set. You may use a date format (the class explicitly supports the date in the following formats: MMDDYY, MMDDYYYY, DDMMYY, DDMMYYYY, YYYYMMDD) to enable the date inserting and updating. Default is MMDDYYYY.

    DelimiterChar - a separator between date fractions (between days and month or month and year). Default is "/".

    yearGreaterThanPresentYear - integer. For the DatePicker column's cell interface two-digit year is assumed to be in the 20th century. So if you enter a date of 12/31/96, the application stores the value of 12/31/1996. You can manipulate the year behavior by using the DatePicker column's yearGreaterThanPresentYear property. If the inserted year is greater than yearGreaterThanPresentYear year value (default is 30) from now (from current date year) the control will use "19" as first two digits for year, otherwise will use "20".


    By implementing in your code an interface with the DataGridCommands class you will be able to save all updates into DataGrid's datasource data object. By using UpdateDataSource method of the class you can easily save all updates that your user made in ASP DataGrid DatePicker Column into bound datasource.

    Syntax
    <RustemSoft:DatePickerColumn DataField="Data Field Name" HeaderText="Header Text"/>

    VB .NET
    ' Define DatePicker variable as an object of DatePickerColumn class
    ' and assign it to the DataGrid1 'Date' column.
    Dim DatePicker As DatePickerColumn = DataGrid1.Columns(5)
    ' Identify "Date" column's foreground color
    DatePicker.ForeColor = Color.DarkMagenta
    ' Identify "Date" column characters' font and size
    DatePicker.Font_Name = "Tahoma"
    DatePicker.Font_Size = FontUnit.Point(8)
    ' Adjust 'Date' column's width
    DatePicker.Width = Unit.Point(60)
    ' Define yearGreaterThanPresentYear property. If the inserted year is greater
    ' than current year plus 20 the control will use "19" as first two digits for year,
    ' otherwise will use "20"
    DatePicker.yearGreaterThanPresentYear = 20

    C#
    // Define DatePicker variable as an object of DatePickerColumn class
    // and assign it to the DataGrid1 'Date' column.
    DatePickerColumn DatePicker = (DatePickerColumn)DataGrid1.Columns[5];
    // Identify "Date" column's foreground color
    DatePicker.ForeColor = Color.DarkMagenta;
    // Identify "Date" column characters' font and size
    DatePicker.Font_Name = "Tahoma";
    DatePicker.Font_Size = FontUnit.Point(8);
    // Adjust 'Date' column's width
    DatePicker.Width = Unit.Point(60);
    // Define yearGreaterThanPresentYear property. If the inserted year is greater
    // than current year plus 20 the control will use "19" as first two digits for year,
    // otherwise will use "20"
    DatePicker.yearGreaterThanPresentYear = 20

    How to define date format and delimiter char?
    VB .NET
    ' Define Date Format as DD.MM.YYYY
    DatePicker.Format = DatePicker.DateFormats.DDMMYYYY
    ' Define separator char
    DatePicker.DelimiterChar = "."

    C#
    // Define Date Format as DD.MM.YYYY
    DatePicker.Format = DatePicker.DateFormats.DDMMYYYY;
    // Define separator char
    DatePicker.DelimiterChar = ".";

    How to turn off error messages? How to define error messages in my native language?
    VB .NET
    ' You may turn error messages off
    DatePicker.ErrMessageVisible = False
    ' You can specify an error message in your native language:
    DatePicker.ErrMessage = "Date Inadmissible ! Réintroduisez svp."

    C#
    // You may turn error messages off
    DatePicker.ErrMessageVisible = false;
    // You can specify an error message in your native language:
    DatePicker.ErrMessage = "Date Inadmissible ! Réintroduisez svp.";


    ASP DataGrid CheckBox Column

    DataGrid CheckBox column accepts and displays true, false values. The RustemSoft DataGrid CheckBox Column control specifies a column in which each cell contains a check box for representing a Boolean value.
    The Check Column in a default state, is used in a similar manner as the standard Microsoft .NET Windows Forms' DataGridBoolColumn binding to a boolean datacolumn and displaying a checkbox. Besides using Boolean data type field as a source field you can use also String data type and any Numeric data types source field of your data source DataTable object. At run time, the DataGrid CheckBox Column contains check boxes in each cell that have two states:

    checked: true for Boolean data type
    "Yes" for a String data type
    1 for a Numeric data type
    unchecked: false for Boolean data type
    "No"(empty string) for a String data type
    0 for a Numeric data type

    By implementing in your code an interface with the DataGridCommands class you will be able to save all updates into DataGrid's datasource data object. By using UpdateDataSource method of the class you can easily save all updates that your user made in ASP DataGrid CheckBox Column into bound datasource.

    Syntax
    <RustemSoft:CheckBoxColumn DataField="Data Field Name" HeaderText="Header Text"/>

    VB .NET
    ' Define CheckBox variable as an object of CheckBox Column class
    ' and assign it to the DataGrid1 'YesNo' column.
    Dim CheckBox As CheckBox Column = DataGrid1.Columns(5)

    C#
    // Define CheckBox variable as an object of CheckBox Column class
    // and assign it to the DataGrid1 'YesNo' column.
    CheckBox Column CheckBox = (CheckBox Column)DataGrid1.Columns[5];


    ASP DataGrid DateTime Column

    You have a DataGrid with a DateTime field that displays the date/time as "2/20/2005 7:00:00 PM". You would like to display only the time in the following format "7:00 PM". You would like to insert a new time in the column or update current time value only. Let us suppose that you are European and would like to see in date field something like "20.02.2005". The ASP DataGrid DateTime Column can help you design the concept that will resolve your needs.
    The DateTime Column is used to allow the user to insert formatted date and time, and to display that date/time in your ASP DataGrid server control interface.

    The ASP DataGrid DateTime Column class has the following useful properties:

    Format - Various formats may be set. You may use a date/time format (like MMDDYY, MMDDYYYY, DDMMYY, DDMMYYYY, YYYYMMDD, HHMM12, HHMMSS12, HHMM24, HHMMSS24) to enable the date/time inserting and updating. Default is MMDDYYYY.

    DefaultValue - any DateTime value. For example, you can set the DefaultValue to today's date. Default is empty DateTime (null/Nothing).

    DelimiterChar - a separator between date/time fractions (between days and month or hours and minutes). Default is "/".

    By implementing in your code an interface with the DataGridCommands class you will be able to save all updates into DataGrid's datasource data object. By using UpdateDataSource method of the class you can easily save all updates that your user made in ASP DataGrid DateTime Column into bound datasource.

    Syntax
    <RustemSoft:DateTimeColumn DataField="Data Field Name" HeaderText="Header Text"/>

    VB .NET
    ' Define DateTime variable as an object of DateTimeColumn class
    ' and assign it to the DataGrid1 'Time' column.
    Dim DateTime As DateTimeColumn = DataGrid1.Columns(5)
    ' Define Time Format
    DateTime.Format = DateTime.DateTimeFormats.HHMMSS12
    ' Define separator char
    DateTime.DelimiterChar = ":"

    C#
    // Define DateTime variable as an object of DateTimeColumn class
    // and assign it to the DataGrid1 'Time' column.
    DateTime ColumnDateTime = (DateTimeColumn)DataGrid1.Columns[5];
    // Define Time Format
    DateTime.Format = DateTime.DateTimeFormats.HHMMSS12;
    // Define separator char
    DateTime.DelimiterChar = ":";

    How to turn off error messages? How to define error messages in my native language?
    VB .NET
    ' You may turn error messages off
    DateTime.ErrMessageVisible = False
    ' You can specify an error message in your native language:
    DateTime.ErrMessage = "Date Inadmissible ! Réintroduisez svp."

    C#
    // You may turn error messages off
    DateTime.ErrMessageVisible = false;
    // You can specify an error message in your native language:
    DateTime.ErrMessage = "Date Inadmissible ! Réintroduisez svp.";


    ASP DataGrid Numeric Column

    This formatted intelligent ASP .NET DataGrid Numeric Column can mask the numbers, digits, decimal and checks the validation, and automatically set the delimiter location. You may input any number. If there is a numeric scale defined with the field, it is used to format the display and the input.

    Note By default the numeric column follows the formatting of the original column. If you define specific parameters (MaxLength, DecimalLength,...) for the column it will accept them. However if the original DataTable's column could not accept your defined parameters it will ignore your settings. For example, the datatype for an original numeric datatable's field is Integer and you give to the DecimalLength parameter some not zero value. For this case the control will not allow your users to insert decimal values. Please choose appropriate datatypes and column settings.


    The ASP DataGrid Numeric Column class has the following useful properties:

    IntegerOnly - as Boolean. Default is False.

    PositiveOnly - as Boolean. Default is False.

    DefaultValue - any numeric value. Default is empty numeric (null/Nothing).

    MinValue - any floating-point value range minimum of the inserted value. Default is empty numeric (null/Nothing).

    MaxValue - any floating-point value range maximum of the inserted value. Default is empty numeric (null/Nothing).

    MaxLength - as integer, specifies a fixed length of whole input area. Default is empty numeric (null/Nothing).

    DecimalLength - as integer, specifies a fixed decimal length. Default is empty numeric (null/Nothing).

    DelimiterChar - decimal separator. Default is ".".

    By implementing in your code an interface with the DataGridCommands class you will be able to save all updates into DataGrid's datasource data object. By using UpdateDataSource method of the class you can easily save all updates that your user made in ASP DataGrid Numeric Column into bound datasource.

    Syntax
    <RustemSoft:NumericColumn DataField="Data Field Name" HeaderText="Header Text"/>

    VB .NET
    ' Define Percent variable as an object of NumericColumn class
    ' and assign it to the DataGrid1 'Percent' column.
    Dim Percent As NumericColumn = DataGrid1.Columns(5)
    ' Identify 'Percent' column's foreground color
    Percent.ForeColor = Color.DarkMagenta
    ' Identify 'Percent' column characters' font and size
    Percent.Font_Name = "Tahoma"
    Percent.Font_Size = FontUnit.Point(8)
    ' Adjust 'Percent' column's width
    Percent.Width = Unit.Point(60)
    ' Define that Percent column accepts positive values only
    Percent.PositiveOnly = True
    ' Define Percent column’s max length
    Percent.MaxLength = 8
    ' Define Percent column’s Decimal Length
    Percent.DecimalLength = 2
    ' Define Percent column’s max possible value
    Percent.MaxValue = 10000
    ' Define Percent column’s min possible value
    Percent.MinValue = 100
    ' Define Percent column’s error message for max value
    Percent.ErrMessageMaxValue = "Too much!"

    C#
    // Define Percent variable as an object of NumericColumn class
    // and assign it to the DataGrid1 'Percent' column.
    NumericColumn Percent = (NumericColumn)DataGrid1.Columns[5];
    // Identify 'Percent' column's foreground color
    Percent.ForeColor = Color.DarkMagenta;
    // Identify 'Percent' column characters' font and size
    Percent.Font_Name = "Tahoma";
    Percent.Font_Size = FontUnit.Point(8);
    // Adjust 'Percent' column's width
    Percent.Width = Unit.Point(60);
    // Define that Percent column accepts positive values only
    Percent.PositiveOnly = true;
    // Define Percent column’s max length
    Percent.MaxLength = 8;
    // Define Percent column’s Decimal Length
    Percent.DecimalLength = 2;
    // Define Percent column’s max possible value
    Percent.MaxValue = 10000;
    // Define Percent column’s min possible value
    Percent.MinValue = 100;
    // Define Percent column’s error message for max value
    Percent.ErrMessageMaxValue = "Too much!";

    How to turn off error messages? How to define error messages in my native language?
    VB .NET
    ' You may turn error messages off
    Percent.ErrMessageVisible = False
    ' You can specify an error message in your native language:
    Percent.ErrMessage = "Date Inadmissible ! Réintroduisez svp."

    C#
    // You may turn error messages off
    Percent.ErrMessageVisible = false;
    // You can specify an error message in your native language:
    Percent.ErrMessage = "Date Inadmissible ! Réintroduisez svp.";


    ASP DataGrid Text Fractions Column

    This formatted intelligent ASP .NET DataGrid Text Fractions Column can mask the text fractions. It gives you ability to manage the IP Address, SS#, Phone numbers, etc., and checks the validation, and automatically set the delimiter location.
    The TextFractionsColumn class is useful in several situations. For example, this control will automatically format a telephone number so when a user enters their phone number like this:

    123-456-7890
    or
    1234567890

    it will automatically change the numbers in the column text updating box.

    Up to 5 text fractions can be defined. By setting the DelimiterChar property up a delimiter symbol for the control can be specified. You can define the overall length of each text fraction and what kind of characters can be inserted in the fraction (alphanumeric, numeric only, etc.).

    To identify each text fraction you must set values of two-dimensional array where properties of the fractions are stored. The first array's element specifies what characters can be inserted into the fraction. It accepts the following values:
    N - numeric characters (0-9) are acceptable only
    L - letters (Aa-Zz) are acceptable only
    A - alphanumeric characters (Aa-Zz0-9) are acceptable only
    Empty - any characters are acceptable
    The second array's element specifies overall fraction's length.

    By implementing in your code an interface with the DataGridCommands class you will be able to save all updates into DataGrid's datasource data object. By using UpdateDataSource method of the class you can easily save all updates that your user made in ASP DataGrid Text Fractions Column into bound datasource.

    Syntax
    <RustemSoft:TextFractionsColumn DataField="Data Field Name" HeaderText="Header Text"/>

    VB .NET
    ' Define PhoneColumn variable as an object of TextFractionsColumn class
    ' and assign it to the DataGrid1 'Phone' column.
    Dim PhoneColumn As TextFractionsColumn = DataGrid1.Columns(5)
    ' Identify 'Phone' column's foreground color
    PhoneColumn.ForeColor = Color.DarkMagenta
    ' Identify 'Phone' column characters' font and size
    PhoneColumn.Font_Name = "Tahoma"
    PhoneColumn.Font_Size = FontUnit.Point(8)
    ' Adjust 'Phone' column's width
    PhoneColumn.Width = Unit.Point(60)
    ' Specify Delimiter Character for the field as space
    PhoneColumn.DelimiterChar = " "

    ' Specify first fraction properties
    ' Alphanumeric symbols only are acceptable for the fraction
    PhoneColumn.FractionsCode(0, 0) = "a"
    ' You can insert 3 symbols only into the first fraction
    PhoneColumn.FractionsCode(0, 1) = 3

    ' Specify second fraction properties
    ' Numeric symbols only are acceptable for the fraction
    PhoneColumn.FractionsCode(1, 0) = "n"
    ' You can insert 3 symbols only into the second fraction
    PhoneColumn.FractionsCode(1, 1) = 3

    ' Specify third fraction properties
    ' Numeric symbols only are acceptable for the fraction
    PhoneColumn.FractionsCode(2, 0) = "n"
    ' You can insert 4 symbols only into the third fraction
    PhoneColumn.FractionsCode(2, 1) = 4

    ' Define PhoneColumn column’s error message for max value
    PhoneColumn.ErrMessageMaxValue = "Not correct phone #!"

    C#
    // Define PhoneColumn variable as an object of TextFractionsColumn class
    // and assign it to the DataGrid1 'Phone' column.
    TextFractionsColumn PhoneColumn = (TextFractionsColumn)DataGrid1.Columns[5];
    // Identify 'Phone' column's foreground color
    PhoneColumn.ForeColor = Color.DarkMagenta;
    // Identify 'Phone' column characters' font and size
    PhoneColumn.Font_Name = "Tahoma";
    PhoneColumn.Font_Size = FontUnit.Point(8);
    // Adjust 'Phone' column's width
    PhoneColumn.Width = Unit.Point(60);
    // Specify Delimiter Character for the field as space
    PhoneColumn.DelimiterChar = " ";

    // Specify first fraction properties
    // Alphanumeric symbols only are acceptable for the fraction
    PhoneColumn.FractionsCode[0, 0) = "a";
    // You can insert 3 symbols only into the first fraction
    PhoneColumn.FractionsCode[0, 1] = 3;

    // Specify second fraction properties
    // Numeric symbols only are acceptable for the fraction
    PhoneColumn.FractionsCode[1, 0] = "n";
    // You can insert 3 symbols only into the second fraction
    PhoneColumn.FractionsCode[1, 1] = 3;

    // Specify third fraction properties
    // Numeric symbols only are acceptable for the fraction
    PhoneColumn.FractionsCode[2, 0] = "n";
    // You can insert 4 symbols only into the third fraction
    PhoneColumn.FractionsCode[2, 1] = 4;

    // Define PhoneColumn column’s error message for max value
    PhoneColumn.ErrMessageMaxValue = "Not correct phone #!";

    How to turn off error messages? How to define error messages in my native language?
    VB .NET
    ' You may turn error messages off
    PhoneColumn.ErrMessageVisible = False
    ' You can specify an error message in your native language:
    PhoneColumn.ErrMessage = "Date Inadmissible ! Réintroduisez svp."

    C#
    // You may turn error messages off
    PhoneColumn.ErrMessageVisible = false;
    // You can specify an error message in your native language:
    PhoneColumn.ErrMessage = "Date Inadmissible ! Réintroduisez svp.";


    ASP DataGrid Text Edit Column

    The RustemSoft ASP DataGrid TextEdit Column gives you a useful TextEdit Field control, which presents an edit window when user selects a cell of the ASP DataGrid TextEdit Column on .NET DataGrid. This provides a pop-up TextEdit field editor that you can call from your code at any time to let users edit the text in a TextEdit field.


    This Text Edit field editor provides more flexibility by updating the TextEdit field to be used in an ASP .NET DataGrid server control's column.


    The ASP DataGrid Text Edit Column TextEdit field editor is useful for showing short document contents, like Memos and emails.


    When using the DataGrid TextEdit Column editor you are automatically provided with all general features, which any typical, contemporary word processor has.

    By implementing in your code an interface with the DataGridCommands class you will be able to save all updates into DataGrid's datasource data object. By using UpdateDataSource method of the class you can easily save all updates that your user made in ASP DataGrid Text Edit Column into bound datasource.

    Syntax
    <RustemSoft:TextEditColumn DataField="Data Field Name" HeaderText="Header Text"/>

    VB .NET
    ' Define CommentColumn variable as an object of TextEditColumn class
    ' and assign it to the DataGrid1 'Comment' column.
    Dim CommentColumn As TextEditColumn = DataGrid1.Columns(5)
    ' Identify 'Comment' column's foreground color
    CommentColumn.ForeColor = Color.DarkMagenta
    ' Identify 'Comment' column characters' font and size
    CommentColumn.Font_Name = "Tahoma"
    CommentColumn.Font_Size = FontUnit.Point(8)
    ' Adjust 'Comment' column's width
    CommentColumn.Width = Unit.Point(60)
    ' Define Name of Interface Page that will be called by clicking on TextEdit button
    CommentColumn.InterfacePageName = "TextEditPage.aspx"
    ' Define width of Interface Page
    CommentColumn.InterfacePageWidth = 280
    ' Define height of Interface Page
    CommentColumn.InterfacePageHeight = 260
    ' Define if the Interface Page is scrollable
    CommentColumn.InterfacePageScroll = True

    C#
    // Define CommentColumn variable as an object of TextEditColumn class
    // and assign it to the DataGrid1 'Comment' column.
    TextEditColumn CommentColumn = (TextEditColumn)DataGrid1.Columns[5];
    // Identify 'Comment' column's foreground color
    CommentColumn.ForeColor = Color.DarkMagenta;
    // Identify 'Comment' column characters' font and size
    CommentColumn.Font_Name = "Tahoma";
    CommentColumn.Font_Size = FontUnit.Point(8);
    // Adjust 'Comment' column's width
    CommentColumn.Width = Unit.Point(60);
    // Define Name of Interface Page that will be called by clicking on TextEdit button
    CommentColumn.InterfacePageName = "TextEditPage.aspx";
    // Define width of Interface Page
    CommentColumn.InterfacePageWidth = 280;
    // Define height of Interface Page
    CommentColumn.InterfacePageHeight = 260;
    // Define if the Interface Page is scrollable
    CommentColumn.InterfacePageScroll = true;


    ASP DataGrid UpDown Column

    The RustemSoft ASP DataGrid UpDown Column represents a datagrid column up-down control that displays a list's selected values. It allows you to show a UpDown control in a Datagrid cell. The control displays in a datagrid cell a single value that is selected from a collection by clicking the up or down buttons of the control. The user can also enter text in the control if the string typed in matched an item in the collection to be accepted.
    To create a collection of objects to display in the UpDown control, you can add or remove the items individually by using the Add and Remove methods.
    You can identify a DataSource parameter for the control. The DataSource is a source for DataGrid UpDown column values list as System.Data.DataTable or System.Data.DataRowView or System.Collections.ArrayList. By defining DisplayMember parameter you can specify a field to display in UpDown column as String (name of table column).
    Use the ASP DataGrid UpDownColumn to create a single selection up-down list control in each cell of ASP .NET DataGrid column. You can control the appearance of the ASP DataGrid UpDownColumn by setting the BackColor, ForeColor, BorderColor, BorderStyle, and other properties.
    The ASP DataGrid UpDownColumn supports data binding. To bind the control to a data source, create a data source, such as a System.Collections.ArrayList object, that contains the items to display in the column. Then, use the DataSource property to bind the data source to the ASP DataGrid UpDownColumn. You can use a DataTable object as a datasource for your UpDownColumn. For this kind of a datasource you need to specify ValueMember and DisplayMember properties.


    By implementing in your code an interface with the DataGridCommands class you will be able to save all updates into DataGrid's datasource data object. By using UpdateDataSource method of the class you can easily save all updates that your user made in ASP DataGrid UpDown Column into bound datasource.

    Syntax
    <RustemSoft:UpDownColumn DataField="Data Field Name" HeaderText="Header Text"/>

    The ASP DataGrid UpDown Column class has the following useful properties:

    DataSource - a source for a DataGrid UpDown column values list as System.Data.DataTable or System.Data.DataRowView or System.Collections.ArrayList

    DisplayMember - field to display in a column cell as String (name of a DataTable column)

    ValueMember - field with values, which binds to up-down control as String (name of table column). Specify the contents of the ValueMember property in cases where you bind data.

    VB .NET
    ' Define StateColumn variable as an object of UpDownColumn class
    ' and assign it to the DataGrid1 'State' column.
    Dim StateColumn As UpDownColumn = DataGrid1.Columns(3)
    Dim al As ArrayList = New ArrayList
    SQL = "SELECT * FROM States"
    DA = New System.Data.OleDb.OleDbDataAdapter(SQL, conStr)
    Dim tblStates As DataTable = New DataTable
    DA.Fill(tblStates)
    Dim row As DataRow
    ' Populate tblStates table's records into al ArrayList
    For Each row In tblStates.Rows
    al.Add(row("State"))
    Next
    StateColumn.DataSource = al
    ' Identify “State” column’s background color
    StateColumn.BackColor = Color.LightGray
    ' Identify “State” column characters’ font and size
    StateColumn.Font_Name = "Tahoma"
    StateColumn.Font_Size = FontUnit.Point(8)
    ' Adjust ‘State’ column’s width
    StateColumn.Width = Unit.Point(30)

    C#
    // Define StateColumn variable as an object of UpDownColumn class
    // and assign it to the DataGrid1 'State' column.
    UpDownColumn StateColumn = (UpDownColumn)DataGrid1.Columns[3];
    ArrayList al = new ArrayList();
    SQL = "SELECT * FROM States";
    DA = new System.Data.OleDb.OleDbDataAdapter(SQL, conStr);
    DataTable tblStates = new DataTable();
    DA.Fill(tblStates);
    // Populate tblStates table's records into al ArrayList
    foreach (DataRow row in tblStates.Rows)
    {
    al.Add(row["State"]);
    }
    StateColumn.DataSource = al;
    // Identify “State” column’s background color
    StateColumn.BackColor = Color.LightGray;
    // Identify “State” column characters’ font and size
    StateColumn.Font_Name = "Tahoma";
    StateColumn.Font_Size = FontUnit.Point(8);
    // Adjust ‘State’ column’s width
    StateColumn.Width = Unit.Point(30);


    ASP .NET DataGridColumns assembly samples deployment

    To deploy a sample web application to a web server, you have to create a Web Setup project in MS VS .NET Environment, build it, copy it to the Web server computer, and run the installer to install the application on the server using the settings defined in your Web Setup project. However it does not work for every particular server. For our users' convenience we have prepared an instruction that describes how to easily deploy the ASP DataGridColumns assembly samples to your web server computer. Please follow the steps:

    Download ASPDataGridColumnsTrial.zip file

    Open MS .NET Development Environment and create a new Web project

    Place the downloaded zip file into the new project's directory. For example, you created project in https://localhost/WebApplication1. On your server hard-drive it suppose to be C:\Inetpub\wwwroot\WebApplication1 directory. Unzip the ASPDataGridColumnsTrial.zip into that directory

    In your new created project's Solution Explorer select Project from the menu bar

    Choose 'Add Existing Item' from the drop down menu

    Browse to and choose Cars.aspx (You need to add .aspx file!)

    And then browse to and choose ComboInterfacePage.aspx

    And then browse to and choose DatePickerObject.aspx

    And then browse to and choose TextEditPage.aspx

    Set Cars.aspx as Start Page for your project. Just right-click on name of the Cars.aspx in Solution Explorer and choose "Set as Start Page"

    You have to have administrator access to your web server. Open windows explorer and navigate to the new project's folder where Samples.mdb Access database is unziped. Right-click and open the properties page, click the security tab, and grant the IUSR_computername user account Modify permissions to the folder and the Samples.mdb file

    Add Reference to ASPDataGridColumnsTrial.dll (see below)

    Run the project

    See more detailed explanation how to setup the ASP assembly sample


    Add a Reference for Visual Studio ASP .NET project

    Suppose you are building a project using Visual Studio.NET, and you decide that you want to start consuming RustemSoft ASP DataGridColumns .NET assembly for an ASP .NET DataGrid control on your .aspx Page. The first step that you will generally take is, you will add a reference to the ASP DataGridColumns .NET assembly, which is residing in some directory on your server. Visual Studio .NET will then add a new item under Solution Explorer called 'References', and it will create a row node underneath it called ASP DataGridColumns.
    In order to add the reference to ASP DataGridColumns .NET assembly please follow the steps:

    Select Project from the menu bar
    Choose Add Reference from the drop down menu
    Click on the Browse button
    Browse to and choose ASPDataGridColumnsTrial.dll

    The second step, your need to import the RustemSoft namespace by adding the line:
    <%@ Register TagPrefix="RustemSoft" Namespace="RustemSoft" Assembly="ASPDataGridColumnsTrial" %>
    to the top of your ASP.NET Web page.

    The Reference to the .NET RustemSoft namespace is a requirement and must be added to a project before the objects in the RustemSoft namespace can be used. The VB .NET Imports statement (or C# using statement) is not a requirement and is simply a coding convenience that allows shorter names to be used. You can add the statement to your code (code behind your aspx):

    VB .NET
    Imports RustemSoft

    C#
    using RustemSoft;

    Download the ASP DataGridColumns .NET assembly code samples for VB.NET and C# that show how you can use the RustemSoft ASP DataGrid Columns in ASP .NET DataGrid control.


    ASP News & Information Source





    Copyright © 2001-2017 Rustemsoft LLC