Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
**Step 1: Creating a Sample Database**


An ASP.NET web application is created and designed in Visual Studio.NET as shown below. Designed sample application

It’s time to connect to the database. We can do it easily using the Server Explorer in Visual Studio.NET.

The Data Link Properties dialog is displayed. The Data Link Properties dialog

Using this dialog, you can connect to any database. By default, it allows you to connect to an SQL Server database. For this example, we need to connect with a Microsoft Access database.

The Connection tab page is opened.


A dialog may appear. Dialog to confirm including database password in connection string

Decide if you want to include a database password in the connection string or not. For this example, we selected Don’t include password. Two database connection objects (oleDbConnection1 and oleDbDataAdapter1) have been created and added. Database connection objects (oleDbConnection1 & oleDbDataAdapter1) created and displayed

So far, we have created database connection objects but still need somewhere to store data after connecting to the database. A DataSet object can store data precisely and we can also generate it easily using VS.NET IDE.

The Generate DataSet dialog is displayed. Here, it is possible to select a name for the new DataSet object to be created, and which tables should be added to it.

A dataSet11 object is added to the designer. DataSet generated and added to designer

Now, its time to open the secret.
Select the GridWeb control and right-click.
Select Worksheets Designer option from the menu.
Selecting Worksheets Designer option

The Worksheet Collection Editor (also called the Worksheets Designer) is displayed. Worksheets Collection Editor dialog

The dialog contains several properties that can be configured to bind Sheet1 to any table in the database.


Clicking the BindColumns property opens the BindColumn Collection Editor. The BindColumn Collection Editor

In the BindColumn Collection Editor, all columns of the Products table are automatically added to the BindColumns collection.


Above, the Products table column name is shown. The width of columns is small so the complete names of some columns are not fully visible.
We have used the Worksheets Designer and now just have to add code to the Page_Load event handler for filling the dataSet11 object with data from the database (using oleDbDataAdapter1) and binding the GridWeb control to dataSet11 by calling its DataBind method.
C#
//Implementing Page_Load event handler
private void Page_Load(object sender, System.EventArgs e)
{
//Checking if there is not any PostBack
if (!IsPostBack)
{
try
{
//Filling DataSet with data
oleDbDataAdapter1.Fill(dataSet11);
//Binding GridWeb with DataSet
GridWeb1.DataBind();
}
finally
{
//Finally, closing database connection
oleDbConnection1.Close();
}
}
}
VB.NET
'Implementing Page_Load event handler
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Checking if there is not any PostBack
If Not IsPostBack Then
Try
'Filling DataSet with data
oleDbDataAdapter1.Fill(dataSet11)
'Binding GridWeb with DataSet
GridWeb1.DataBind()
Finally
'Finally, closing database connection
oleDbConnection1.Close()
End Try
End If
End Sub

Compile and run the application: either press Ctrl+F5 or click Start. Running the application

After compilation, the WebForm1.aspx page is opened in a browser window with all the data loaded from the database. Data loaded into the GridWeb control from the database

When data is loaded into the GridWeb control it provides users with control over the data. A number of different types of of data manipulation features are offered by the GridWeb.
Aspose.Cells.GridWeb automatically creates appropriate validation rules for all bound columns according to the data types defined in the database. See the validation type of a cell by hovering the cursor over it. Checking validation type of a cell

Here, the selected cell contains the
To delete a row, select a row (or any cell in the row), right-click and select Delete Row. Selecting the Delete Row option from menu

The row would be deleted instantly. Grid data (after a row is deleted)

Edit data in cells or rows and then click Save or Submit to save the changes.

A new row is added to the sheet at the end of other rows. New row added to Grid

At the left of the new row is an asterisk
, indicating that the row is new.

At the moment, the prices in the Product Price column are shown as numeric values. It is possible to make them look like currency.



The application so far only allows its users to view table data. Users can edit data in the GridWeb control but, when closing the browser and opening the database, nothing has changed. The changes made are not saved to the database.
The following example adds code to the application so that the GridWeb can save changes to the database.

C#
//Implementing the event handler for SaveCommand event
private void GridWeb1_SaveCommand(object sender, System.EventArgs e)
{
try
{
//Getting the modified data of worksheet as a DataSet
DataSet dataset = (DataSet)GridWeb1.WorkSheets[0].DataSource;
//Updating database according to modified DataSet
oleDbDataAdapter1.Update(dataset);
}
finally
{
//Closing database connection
oleDbConnection1.Close();
}
}
VB.NET
'Implementing the event handler for SaveCommand event
Private Sub GridWeb1_SaveCommand(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridWeb1.SaveCommand
Try
'Getting the modified data of worksheet as a DataSet
Dim dataset As DataSet = CType(GridWeb1.WorkSheets(0).DataSource, DataSet)
'Updating database according to modified DataSet
oleDbDataAdapter1.Update(dataset)
Finally
'Closing database connection
oleDbConnection1.Close()
End Try
End Sub
You can also check the code added to the GridWeb1_SaveCommand event handler Code added to the GridWeb1_SaveCommand event handler

Save changes to the database using the Save button now definitely saves them.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.