[Download Code]
The DataGridHelper.aspx page demonstrates the use of DataGridHelper control. A live demo can be accessed at http://www.dotneteer.com/projects/DataGridHelper/v1/DataGridHelperTest.aspx.
This page has the identical functionality as the TypicalDataAccessPage.aspx. It was also created in nearly the same way. The only difference is that we drop the DataGridHelper control into the page instead of writing all the code. One of the easiest ways to drop the control is to right click on one of the tabs in the tool box and click “Add/Remove items…” from the dropdown menu. Then browse and select the WebDataControl.dll file that is in the download that accompanies this article.
We then need to add some code to respond to the Page_Init event and the LoadData event of the DataGridHelper control. The following shows the code behind:
private void DataGridHelper_LoadData(object Sender,
Dotneteer.WebDataControls.LoadDataEventArgs e)
{
DataSet ds = new DataSet();
sqlDataAdapterProducts.Fill(ds);
e.DataSource = ds;
}
private void DataGridHelperTest_Init(object sender, System.EventArgs e)
{
dataGridHelper.DataGrid = dataGridProducts;
}
In the Init event, we need a single line of code to attach the DataGrid control to the DataGridHelper control.
In the LoadData event, we create the data source and assign it to the DataSource property of the event argument. That is it! We have a functional page.
In the next section, we will further discuss the features of DataGridHelper control and conclude this article.