Aspose.Cells.GridWeb.Examples.CSharp.Miscellaneous.DataBind.DataBind3.Page_Load C# (CSharp) Метод

Page_Load() защищенный Метод

protected Page_Load ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Результат void
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && !GridWeb1.IsPostBack)
            {
                // Creates the collection.
                MyCollection list = new MyCollection();
                System.Random rand = new System.Random();
                for (int i = 0; i < 5; i++)
                {
                    // Create custom record object and set properties
                    MyCustomRecord rec = new MyCustomRecord();
                    rec.DateField1 = DateTime.Now;
                    rec.DoubleField1 = rand.NextDouble();
                    rec.IntField1 = rand.Next();
                    rec.StringField1 = "ABC_" + i;
                    ((IList)list).Add(rec);
                }

                // Create web worksheet object
                WebWorksheet sheet = GridWeb1.WebWorksheets[0];

                // Uses the collection as datasource.
                sheet.DataSource = list;

                // Creates bind columns.
                sheet.CreateAutoGenratedColumns();

                // Sets the DateFiled1's validation to DateTime.
                sheet.BindColumns["DateField1"].Validation.ValidationType = ValidationType.DateTime;

                // Binding.
                sheet.DataBind();
            }
        }