2
votes

I have a custom edit form made for ASPxGridView but have a big problem retrieving the values when inserting.

The template:

<Templates>
    <EditForm>
        Company Name: <dx:ASPxTextBox ID="CompanyName" runat="server" />
        Company Mail: <dx:ASPxTextBox ID="Email" runat="server" />

        <dx:ASPxGridViewTemplateReplacement ID="UpdateButton" ReplacementType="EditFormUpdateButton" runat="server" />
        <dx:ASPxGridViewTemplateReplacement ID="CancelButton" ReplacementType="EditFormCancelButton" runat="server" />

    </EditForm>
</Templates>

it fails, the e.NewValues are empty

protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
{
    string CompanyName = (string)e.NewValues["CompanyName"]; // (or .toString())
    string Email = (string)e.NewValues["Email"];
}

Does anyone know how to solve this?

Thanks

2

2 Answers

5
votes

The e.NewValues collection is empty because you did not bind editors to data. To make your code work, it should be changed as follows:

Company Name: <dx:ASPxTextBox ID="CompanyName" runat="server" Value="<% #Bind('CompanyName')%>"/>
Company Mail: <dx:ASPxTextBox ID="Email" runat="server" Value="<% #Bind('Email')%>"/>
0
votes

It looks like your trying to assign the NewValues to a string. The RowUpdatingEvent seems like a better event to get the NewValues; you would also have access to the OldValues. Check it out: http://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewASPxGridView_RowUpdatingtopic