How to insert data into Infragistics UltraWebGrid via InsertDBRow
I would like to add rows to the UltraWebGrid directly on the grid that is connected to the ObjectDataSource. According to the documentation, I have to use the InsertDBRow method (there is also UpdateDBRow and DeleteDBRow) to deal with database persistence.
Does anyone have an example of what the intended use of these methods is? (I have already tried the help forum and Infragistics, with no success)
I am planning to use this grid on a webpage for quick data entry. If anyone has any clues in this direction I would appreciate it.
I am using Infragistics 2008 v1, ASP.Net.
a source to share
You can use a generic function to handle the CRUD of the grid, or to call one of the DBRow functions (InsertDBRow, UpdateDBRow, and DeleteDBRow) directly each time. An example is shown below:
protected void UltraWebGrid_UpdateRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)
{
CRUDHelper(e, UltraWebGrid);
}
private void CRUDHelper(Infragistics.WebUI.UltraWebGrid.RowEventArgs e, UltraWebGrid pUltraWebGrid)
{
switch (e.Row.DataChanged)
{
case Infragistics.WebUI.UltraWebGrid.DataChanged.Added:
pUltraWebGrid.InsertDBRow(e.Row);
break;
case Infragistics.WebUI.UltraWebGrid.DataChanged.Modified:
pUltraWebGrid.UpdateDBRow(e.Row);
break;
case Infragistics.WebUI.UltraWebGrid.DataChanged.Deleted:
pUltraWebGrid.DeleteDBRow(e.Row);
break;
}
}
a source to share
You must create a new instance of the UltraGridRow class and pass it to the UltraWebGrid InsertDBRow .
Here is an example of inserting a row using InsertDBRow.
// Create new UltraGridRow (using the object[] constructor)
var newRow = new UltraGridRow( new[] { "My First Value" , "My Second Value" } );
UltraWebGrid1.InsertDBRow( newRow );
a source to share