Click here to Skip to main content
13,346,966 members (71,384 online)
Click here to Skip to main content
Add your own
alternative version


22 bookmarked
Posted 23 Mar 2010

An Innovative Architecture to Develop Business Web Forms (3) - Configure GridView

, 23 Mar 2010
Rate this:
Please Sign up or sign in to vote.
An Innovative Architecture to Develop Business Web Forms (3) - Configure GridView


This is the third article in the series to introduce an innovative architecture to develop web forms in enterprise software which is high performance, productivity, configurability and maintainability than writing ASPX/MVC code directly. The article introduces how to configure gridview for search results in a web form. Before going forward, we strongly suggest you to take a look at the articles in the series before as the following catalog:

In the last article on introducing "query", we have known a QueryResult returned from an IDynamicPage instance will be bound to GridView automatically by the RapidWebDev UI framework. This article introduces the schema of GridView configuration. Let's have a look at a fragment as below:

<GridViewPanel HeaderText="Concrete Data Query Results"

    EntityName="Concrete Data Record"





    <ViewButton />
    <EditButton />
    <DeleteButton />
        <Field FieldName="Name" HeaderText="Name" />
        <Field FieldName="Value" HeaderText="Value" />
        <Field FieldName="DeleteStatus" HeaderText="Status" Width="60">
                <Case Value="NotDeleted">&lt;span style='color:green'&gt;
                <Case Value="Deleted">&lt;span style='color:red'&gt;
        <Field FieldName="LastUpdatedBy" HeaderText="ModifiedBy" Align="Center">
            <Transform-Callback Type="XXX"/>
        <Field FieldName="LastUpdatedDate" HeaderText="ModifiedOn" 

			Align="Center" Width="150" />
        <RowView FieldName="Description" />


  • HeaderText: GridView section header text.
  • EntityName: The entity name displaying in gridview, seeing in the following screenshot.
  • PrimaryKeyFieldName: The primary key field of the binding entity. The gridview only supports single unique key.
  • PageSize: Page size of grid view. The default value is 25.
  • EnabledCheckBoxField: Whether to render a checkbox column into each row of gridview.
  • ExecuteQueryWhenLoaded: Whether to execute query when the web page is loaded.
  • EnabledColumnMove: Whether to allow drag and drop to reorder the columns.
  • EnabledColumnResize: Whether to turn off column resizing of the grid.
  • DefaultSortField: The default sort field name which should be configured in inner Field element.
  • DefaultSortDirection: The candidate values are ASC | DESC.

* Tips: HeaderText and EntityName support manifest variables in the format as $VariableName$ which VariableName should be put into IApplicationContext.TempVariables as a key in code behind. And it also supports globalization identifier as "$Namespace.ClassName.PropertyName, AssemblyName$" whatever the static property is internal, protected or private.

Row View, Edit and Delete Button

  • ViewButton: Display view button in each row if ViewButton element is configured. The button can be configured as an Image or button.
  • EditButton: Display edit button in each row if EditButton element is configured. The button can be configured as an Image or button.
  • DeleteButton: Display delete button in each row if DeleteButton element is configured. The button can be configured as an Image or button.

Alternatively, when you configured ViewButton, EditButton and DeleteButton in XML, you can also control the visibility of them for each row by data in code behind. See the internal IDynamicPage.

/// <summary>
/// The interface restraints the dynamic page. 
/// </summary>
interface IDynamicPage : IDynamicComponent
    /// <summary>
    /// The method will be invoked when the data item binding to grid rows.
    /// </summary>
    /// <param name="e"></param>
    void OnGridRowControlsBind(GridRowControlBindEventArgs e);

/// <summary>
/// Event argument to manage visibility of controls in gridview rows of dynamic page.
/// </summary>
class GridRowControlBindEventArgs : EventArgs
    /// <summary>
    /// Gets binding data item which used for callback to set control visibility by data.
    /// </summary>
    object DataItem { get; private set; }

    /// <summary>
    /// Sets/gets true to display checkbox column. Default value is true.
    /// </summary>
    bool ShowCheckBoxColumn { get; set; }

    /// <summary>
    /// Sets/gets true to display view button in buttons column. Default value is true.
    /// </summary>
    bool ShowViewButton { get; set; }

    /// <summary>
    /// Sets/gets true to display edit button in buttons column. Default value is true.
    /// </summary>
    bool ShowEditButton { get; set; }

    /// <summary>
    /// Sets/gets true to display delete button in buttons column. Default value is true.
    /// </summary>
    bool ShowDeleteButton { get; set; }

GridView Fields

You can configure a common Field or RowView inner of Fields.

Field Schema


  • FieldName: The binding field of entities. It can be any property accessor alternatively, like Category.Name, "DicionaryKey", Properties "Name", etc.
  • HeaderText: The column header text.
  • SortingFieldName: The sorting field name. If no value has been specified, it uses FieldName for sorting by default. The explicit sorting field is used for the requirement that sorts by a field different to display.
  • Sortable: Whether the column is sortable
  • Resizable: Whether the column is resizable
  • Css: custom CSS for all cells in the column
  • Width: The initial width in pixels of the column, defaults to auto.
  • Align: Text alignment inner of the column
  • Hidden: Whether to hide the column initially. Users can show the hidden columns on client.

HeaderText supports manifest variables in the format as $VariableName$ which VariableName should be put into IApplicationContext.TempVariables as a key in code behind. And it also supports globalization identifier as "$Namespace.ClassName.PropertyName, AssemblyName$" whatever the static property is internal, protected or private.


You can configure data transform to a field for converting the value of source entity for display. There are 4 transformers supported in RapidWebDev v1.51.

  • Transform-ToString-Parameter: Configure a format parameter to convert the field value to string. E.g, DateTime.Now.ToString(string format)
  • Transform-VariableString: Configure custom output integrated with runtime data. Take an example, you're required to display a link like <a href="/article.aspx?id=XXX">Text</a>. You can configure the element value as <a href="/article.aspx?id=$Id$">$Text$</a>. $Marker$ can be replaced by the framework before rendering it into UI. Marker should be an accessible property of the binding entity, a variable in IApplicationContext.TempVariables or globalization variable marker.
  • Transform-Callback: Use callback implementation of interface IGridViewFieldValueTransformCallback to process field value at runtime.
    /// <summary>
    /// Format input field value.
    /// </summary>
    /// <param name="fieldName"></param>
    /// <param name="fieldValue"></param>
    /// <returns></returns>
    string Format(string fieldName, object fieldValue);
  • Transform-Switch: like a syntax in C# language. If field value matches a Case, the inner text fragment is rendered. If no Case matched, the field value is output directly. The following XML fragment intends to wrap HTML tags around field value.
        <Case Value="Enabled" CaseSensitive="true">
    	&lt;span style="color:green"&gt;Enabled&lt;/span&gt;</Case>
        <Case Value="Disabled" CaseSensitive="true">
    	&lt;span style="color:red"&gt;Disabled&lt;/span&gt;</Case>

Row View

Row view is used to render any content related to the entity, even custom HTML fragment. When you're developing in .NET 3.5 SP1, you can return anonymous objects from Query method of IDynamicPage implementation that the anonymous object has a property with assembling custom content for the row view.

  • FieldName: The field displayed in row view of grid.
  • Css: Apply custom CSS classes to row view during rendering.
  • TagName: The HTML tag wraps the field value. The default tag name is "p".

What's RapidWebDev

Official Website:

RapidWebDev is an infrastructure that helps engineers to develop enterprise software solutions in Microsoft .NET easily and productively. It consists of an extendable and maintainable web system architecture with a suite of generic business model, APIs and services as fundamental functionalities needed in development for almost all business solutions. So when engineers develop solutions in RapidWebDev, they can have a lot of reusable and ready things then they can focus more on business logics implementation. In practice, we can save more than 50% time on developing a high quality and performance business solution than direct ASP.NET coding.


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

President TCWH
China China
I've worked as a software architect and developer based on Microsoft .NET framework and web technology since 2002, having rich experience on SaaS, multiple-tier web system and website development. I've devoted into open source project development since 2003, and have created 3 main projects including DataQuicker (ORM), ExcelQuicker (Excel Report Generator), and RapidWebDev (Enterprise-level CMS)

I worked in BenQ (8 mo), Bleum (4 mo), Newegg (1 mo), Microsoft (3 yr) and Autodesk (5 yr) before 2012. Now I own a startup company in Shanghai China to deliver the exceptional results to global internet users by leveraging the power of Internet and the local excellence.

You may also be interested in...


Comments and Discussions

GeneralGood one but needs formatting... Pin
Sandeep Mewara23-Mar-10 7:11
memberSandeep Mewara23-Mar-10 7:11 
GeneralRe: Good one but needs formatting... [modified] Pin
Eunge23-Mar-10 17:53
memberEunge23-Mar-10 17:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180111.1 | Last Updated 23 Mar 2010
Article Copyright 2010 by Eunge
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid