protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack && !GridWeb1.IsPostBack)
{
// Create dataset object
this.dataSet11 = new DataSet1();
// Create web worksheet object
WebWorksheet sheet = GridWeb1.WebWorksheets[0];
// Specifies the datasource for the sheet.
sheet.DataSource = dataSet11;
sheet.DataMember = "Products";
// Creates in-sheet column headers.
sheet.EnableCreateBindColumnHeader = true;
// Data cells begin at row 1;
sheet.BindStartRow = 1;
// Creates the data field column automatically.
sheet.CreateAutoGenratedColumns();
// Modifies a column's number type.
sheet.BindColumns["UnitPrice"].NumberType = NumberType.Currency3;
// The "product name" field is required.
Aspose.Cells.GridWeb.Validation v = new Aspose.Cells.GridWeb.Validation();
v.IsRequired = true;
sheet.BindColumns["ProductName"].Validation = v;
// Modifies column headers' background color.
for (int i = 0; i < sheet.BindColumns.Count; i++)
{
sheet.BindColumns[i].ColumnHeaderStyle.BackColor = Color.SkyBlue;
}
// Create demo database object
ExampleDatabase db = new ExampleDatabase();
// Create path to database file
string path = (this.Master as Site).GetDataDir();
// Create connection string
db.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "\\Miscellaneous\\Database\\demos.mdb";
try
{
// Loads data from database.
db.oleDbDataAdapter1.Fill(dataSet11);
}
finally
{
// Close connection
db.oleDbConnection1.Close();
}
// Binding.
sheet.DataBind();
}
}