Back to Devexpress

ASPxDataInsertingEventArgs.NewValues Property

aspnet-devexpress-dot-web-dot-data-dot-aspxdatainsertingeventargs.md

latest7.3 KB
Original Source

ASPxDataInsertingEventArgs.NewValues Property

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

Declaration

csharp
public OrderedDictionary NewValues { get; }
vb
Public ReadOnly Property NewValues As OrderedDictionary

Property Value

TypeDescription
OrderedDictionary

A OrderedDictionary object that contains a dictionary of the new field name/value pairs for the row to be inserted.

|

Remarks

Note

To set or get a value for a row, use a field name of a corresponding column.

Example

Note

For a full example, refer to the ASPxGridView - Editing an in-memory dataset.

csharp
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.

asp-net-web-forms-grid-entitydatasource-and-common-scenarios/CS/GridEntityFramework/CustomEditingCapabilities.aspx.cs#L37

csharp
var product = new Product();
product.ProductName = (string)e.NewValues["ProductName"];
product.UnitPrice = (decimal)e.NewValues["UnitPrice"];

asp-net-web-forms-grid-create-master-detail-grid-at-runtime/CS/MasterDetailGrids/Default.aspx.cs#L111

csharp
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

csharp
{
    InsertNewItem(e.NewValues);
    CancelEditing(e);

asp-net-web-forms-grid-use-cascading-combo-boxes-in-inline-edit-mode/CS/MultiCombo/Default.aspx.cs#L86

csharp
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

csharp
DataTable table = GetTable();
table.Rows.Add(new Object[] { e.NewValues["ID"], e.NewValues["Name"] });

asp-net-web-forms-grid-entitydatasource-and-common-scenarios/VB/GridEntityFramework/CustomEditingCapabilities.aspx.vb#L37

vb
Dim product = New Product()
product.ProductName = CStr(e.NewValues("ProductName"))
product.UnitPrice = CDec(e.NewValues("UnitPrice"))

asp-net-web-forms-grid-create-master-detail-grid-at-runtime/VB/MasterDetailGrids/Default.aspx.vb#L115

vb
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

vb
Protected Sub Grid_RowInserting(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxDataInsertingEventArgs)
    InsertNewItem(e.NewValues)
    CancelEditing(e)

asp-net-web-forms-grid-use-cascading-combo-boxes-in-inline-edit-mode/VB/MultiCombo/Default.aspx.vb#L84

vb
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

vb
Dim table As DataTable = GetTable()
table.Rows.Add(New Object() {e.NewValues("ID"), e.NewValues("Name")})
Session("Table") = table

See Also

ASPxDataInsertingEventArgs Class

ASPxDataInsertingEventArgs Members

DevExpress.Web.Data Namespace