Grid implementation of ASP. NET Server control development (III)

Source: Internet
Author: User

Here is the implementation code for Gridcolumnseditor:

GridColumnsEditor.cs

using System ; using system.collections.generic;using system.componentmodel.design;using system.linq;using System.Text;using System.threading.tasks;using system.web.ui.webcontrols;namespace aspnetservercontrol{public class        Gridcolumnseditor:collectioneditor {private type[] types;        <summary>///constructors///</summary>//<param name= "type" > control type </param> Public gridcolumnseditor (Type type): Base (type) {types = new type[] {T        Ypeof (BoundField)}; }///<summary>///Get the data types that this collection Editor can contain///</summary>//<returns> type collection </re        turns> protected override type[] Createnewitemtypes () {return types; }    }}
Gridcolumnseditor inherits from Collectioneditor,collectioneditor can provide the user with an editing interface and assemble most of the data types.

In the constructor gridcolumnseditor (type type), only one BoundField field is implemented, and if additional fields are required, you can add them later. Like what

types = new type[] {                 typeof (BoundField), typeof (CheckField)            };
Let's take a look at the implementation of the BoundField field

<summary>    ///table Data binding columns///    </summary>    [ToolboxItem (false)]    [ParseChildren (True)]    [PersistChildren (false)] public    class Boundfield:gridcolumn    {    }
BoundField inherits from the GridColumn class, where there is also a ParseChildren attribute, mainly for nesting.

Let's take a look at the implementation of GridColumn

Using system;using system.collections.generic;using system.componentmodel;using system.linq;using System.Text;using System.web.ui;namespace aspnetservercontrol{///<summary>///Table Grieki Class (abstract Class)///</summary> [Toolboxi TEM (FALSE)] [ParseChildren (true)] [PersistChildren (false)] [Defaultproperty ("HeaderText")] public class Gridco        lumn:controlbase {private String _headertext = String.Empty; <summary>/////title bar display text///</summary> [Category (Categoryname.options)] [defaul                TValue ("")] [Description ("title bar display text")] public string HeaderText {get {            return _headertext;            } set {_headertext = value;        }} private String _datafield = String.Empty; <summary>////Field name///</summary> [Category (Categoryname.options)] [defaultval    UE ("")]    [Description ("Field name")] public string DataField {get {return _dataf            Ield;            } set {_datafield = value; }        }    }}
GridColumn also inherits from Controlbase, so GridColumn is actually a control, but we nest it in a grid.

When defining the properties of columns in a grid, we use the Gridcolumncollection class, which is a GridColumn collection with the following code.

public class gridcolumncollection:collection<gridcolumn>    {public        gridcolumncollection (controlbase Parent)        {        }    }

Looking again at the GridColumn class, we define the HeaderText and DataField properties, which are the attributes we add to BoundField when we edit the grid in the Default.aspx page.

In this case, the entire grid package is complete.

If you combine Jquerymobile, you can mark the output in the grid's render function according to the Jquerymobile table.




Grid implementation of ASP. NET Server control development (III)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.