Reviewed: Three ASP.NET DataGrid Components - ' ComponentOne WebGrid' (
Page 2 of 5 )
ComponentOne WebGrid
WebGrid is a full-featured, intuitive part of a much larger suite of tools from ComponentOne. This suite, called Studio Enterprise, contains components which work with both ASP.NET and Windows Forms.
ADVERTISEMENT
This control looks and feels the most like the ASP.NET data grid, so if you want to change relatively little about the way you're writing code (or you have a lot of DataGrid code to replace), this may be the best option.
WebGrid both looks and acts much like the ASP.NET DataGrid. Editing is handled on a row-by-row basis.
To get to the basic functionality, you need to write a handful of code:
void C1WebGrid1_PageIndexChanged(object sender, C1PageChangedEventArgs e)
{
C1WebGrid1.CurrentPageIndex = e.NewPageIndex;
DataBind();
}
void C1WebGrid1_SortCommand(object sender, C1SortCommandEventArgs e)
{
theView.Sort = e.SortExpression;
DataBind();
}
void C1WebGrid1_EditCommand(object source, C1CommandEventArgs e)
{
C1WebGrid1.EditItemIndex = e.Item.ItemIndex;
DataBind();
}
void C1WebGrid1_DeleteCommand(object source, C1CommandEventArgs e)
{
theView[e.Item.ItemIndex].Delete();
DataBind();
}
void C1WebGrid1_CancelCommand(object source, C1CommandEventArgs e)
{
C1WebGrid1.EditItemIndex = -1;
DataBind();
}
void C1WebGrid1_UpdateCommand(object source, C1CommandEventArgs e)
{
// Calculate the DataSetIndex since they control doesn't support it
int dataSetIndex = e.Item.ItemIndex +
(C1WebGrid1.CurrentPageIndex * C1WebGrid1.PageSize);
// Get the data row
DataRow row = theView[dataSetIndex].Row;
object dataItem = e.Item.DataItem;
// Try to cast it to our customer
SampleDataSet.CustomersRow customer = row as SampleDataSet.CustomersRow;
// If the customer is correct
if (customer != null)
{
// Save the items
customer.CompanyName = ((TextBox)e.Item.Cells[1].Controls[0]).Text;
customer.ContactName = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
customer.ContactTitle = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
customer.Phone = ((TextBox)e.Item.Cells[4].Controls[0]).Text;
customer.City = ((TextBox)e.Item.Cells[5].Controls[0]).Text;
customer.Region = ((TextBox)e.Item.Cells[6].Controls[0]).Text;
}
C1WebGrid1.EditItemIndex = -1;
DataBind();
}
This code is identical to the code we put in the ASP.NET DataGrid, except that the event handlers pass ComponentOne argument types. The database editing is on par with ASP.NET, no more, no less.
ComponentOne WebGrid
But WebGrid doesn't simply duplicate what you get from the built-in ASP.NET DataGrid. It is packed with impressive functionality: sorting (that includes sorting markers and automatic support for descending), sizable and orderable columns, and grouping support.
On the downside, it was downright difficult to find good references to some of those features, such as adding value lists and page by demand (where the actual loading from the database only happens incrementally). While the documentation is adequate, I would have liked to see better MSDN integration; for example, I could not filter for only ComponentOne's documentation, which made searching more laborious.
The biggest reason to use the ComponentOne WebGrid is if you are already using the ASP.NET grid and want an in-place replacement with some additional features.
You can buy the ComponentOne WebGrid control all by itself for $399. The control is also part of the company's ASP.NET set of controls for $649, or every .NET control they have for $899. There are no runtime fees.