2

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

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Eric Herlitz
  • 25,354
  • 27
  • 113
  • 157

2 Answers2

5

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')%>"/>
DevExpress Team
  • 11,338
  • 2
  • 24
  • 23
  • I am facing the same problem, but I my controls are already bound by using #Bind. What I noticed is that only the controls that are inside my ASPxPageControl lose their values. Their values won't be sent through e.NewValues not matter what I do. @DevExpressTeam – MMalke Oct 30 '14 at 16:42
0

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

Rich
  • 1,895
  • 3
  • 26
  • 35