Data binding of DataGrid controls using custom data sources

xiaoxiao2021-03-06  87

Custom Set Class ///

/// Collection Summary Description. /// public class collection: system.collections.collectionBase {public colic {for (int i = 0; i <10; i ) {base.innerList.Add (New Element (I, String.Format ("A [{0}]", I))))));}}}

The collection element class public class Element {private string name; public string ValueName {get {return name;}} private int valu; public int Value {get {return valu;}} public Element (int val, string nam) {name = nam ; VALU = VAL;}} A summary description of the rear code ///

/// WebForm1 of ASPX. /// public class WebForm1: System.Web.UI.Page {protected System.Web.UI.WebControls.DataGrid DataGrid1; private void Page_Load (object sender, System.EventArgs e) {DataGrid1.DataSource = new Collection (); DataGrid1.databind ();

#Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} ///

/// Designer Supports the required method - Do not use the code editor to modify the // / this method. /// private () {this.load = new system.eventhandler (this.page_load);

转载请注明原文地址:https://www.9cbs.com/read-106059.html

New Post(0)