aspnet-devexpress-dot-web-dot-data-dot-aspxdatainsertingeventargs.md
Gets a dictionary that contains the new field name/value pairs for the row to be inserted.
Namespace : DevExpress.Web.Data
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public OrderedDictionary NewValues { get; }
Public ReadOnly Property NewValues As OrderedDictionary
| Type | Description |
|---|---|
| OrderedDictionary |
A OrderedDictionary object that contains a dictionary of the new field name/value pairs for the row to be inserted.
|
Note
To set or get a value for a row, use a field name of a corresponding column.
Note
For a full example, refer to the ASPxGridView - Editing an in-memory dataset.
protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) {
ds = (DataSet)Session["DataSet"];
ASPxGridView gridView = (ASPxGridView)sender;
DataTable dataTable = gridView.GetMasterRowKeyValue() != null ? ds.Tables[1] : ds.Tables[0];
DataRow row = dataTable.NewRow();
e.NewValues["ID"] = GetNewId();
IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator();
enumerator.Reset();
while(enumerator.MoveNext())
if(enumerator.Key.ToString() != "Count")
row[enumerator.Key.ToString()] = enumerator.Value;
gridView.CancelEdit();
e.Cancel = true;
dataTable.Rows.Add(row);
}
The following code snippets (auto-collected from DevExpress Examples) contain references to the NewValues property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
var product = new Product();
product.ProductName = (string)e.NewValues["ProductName"];
product.UnitPrice = (decimal)e.NewValues["UnitPrice"];
SqlCommand cmd = new SqlCommand(query, DataHelper.GetConnection());
cmd.Parameters.Add("@ProductName", SqlDbType.NVarChar).Value = e.NewValues["ProductName"];
cmd.Parameters.Add("@SupplierID", SqlDbType.Int).Value = randomizer.Next(1, 29);
asp-net-web-forms-gridview-custom-buttons-in-batch-edit-mode/CS/T114462/Default.aspx.cs#L53
{
InsertNewItem(e.NewValues);
CancelEditing(e);
protected void grid_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) {
SaveOrInsertData(e.NewValues);
}
aspxgridview-use-external-buttons-to-edit-records/CS/Solution/Default.aspx.cs#L68
DataTable table = GetTable();
table.Rows.Add(new Object[] { e.NewValues["ID"], e.NewValues["Name"] });
Dim product = New Product()
product.ProductName = CStr(e.NewValues("ProductName"))
product.UnitPrice = CDec(e.NewValues("UnitPrice"))
Dim cmd As New SqlCommand(query, DataHelper.GetConnection())
cmd.Parameters.Add("@ProductName", SqlDbType.NVarChar).Value = e.NewValues("ProductName")
cmd.Parameters.Add("@SupplierID", SqlDbType.Int).Value = randomizer.Next(1, 29)
asp-net-web-forms-gridview-custom-buttons-in-batch-edit-mode/VB/T114462/Default.aspx.vb#L44
Protected Sub Grid_RowInserting(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxDataInsertingEventArgs)
InsertNewItem(e.NewValues)
CancelEditing(e)
Protected Sub grid_RowInserting(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxDataInsertingEventArgs)
SaveOrInsertData(e.NewValues)
End Sub
aspxgridview-use-external-buttons-to-edit-records/VB/Solution/Default.aspx.vb#L63
Dim table As DataTable = GetTable()
table.Rows.Add(New Object() {e.NewValues("ID"), e.NewValues("Name")})
Session("Table") = table
See Also
ASPxDataInsertingEventArgs Class