DetailsViewUpdateEventArgs and NULLReference Exception

S

studio60podcast

I'm defining the ItemUpdating event for a DetailsView control, but when
I try to access the e.NewValues collection, it's throwing a
NULLReference exception. Any thoughts?

<asp:DetailsView id="dvConsultantDetails" runat="server"
GridLines="none" CssClass="textBlue12"
AutoGenerateRows="false" DefaultMode="Edit"
OnModeChanging="dvConsultantDetails_ModeChanging"
OnItemUpdating="dvConsultantDetails_ItemUpdating">
<Fields>
<asp:BoundField DataField="name" HeaderText="Name">
<ControlStyle CssClass="formField" width="305" />
<HeaderStyle CssClass="formField" Width="100" />
</asp:boundfield>
<asp:BoundField DataField="abbr" HeaderText="Abbreviation">
<ControlStyle CssClass="formField" width="305" />
<HeaderStyle CssClass="formField" Width="100" />
</asp:boundfield>
<asp:BoundField DataField="vid" HeaderText="Vendor ID">
<ControlStyle CssClass="formField" width="305" />
<HeaderStyle CssClass="formField" Width="100" />
</asp:boundfield>
<asp:BoundField DataField="address" HeaderText="Address">
<ControlStyle CssClass="formField" width="305" />
<HeaderStyle CssClass="formField" Width="100" />
</asp:boundfield>
<asp:BoundField DataField="phone" HeaderText="Phone">
<ControlStyle CssClass="formField" width="305" />
<HeaderStyle CssClass="formField" Width="100" />
</asp:boundfield>
<asp:BoundField DataField="fax" HeaderText="Fax">
<ControlStyle CssClass="formField" width="305" />
<HeaderStyle CssClass="formField" Width="100" />
</asp:boundfield>
<asp:BoundField DataField="email" HeaderText="E-Mail">
<ControlStyle CssClass="formField" width="305" />
<HeaderStyle CssClass="formField" Width="100" />
</asp:boundfield>
<asp:CommandField ButtonType="Button" ShowEditButton="True">
<ControlStyle CssClass="formField" />
</asp:commandfield>
</Fields>
</asp:DetailsView>

protected void dvConsultantDetails_ItemUpdating(object sender,
DetailsViewUpdateEventArgs e)
{
string lsName = e.NewValues["name"].ToString();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top