DetailsViewInsertEventArgs.Values["xyz"] is null

J

Justin Dutoit

Hi folks. I've been learning about the DetailsView, and its Insert function.
I get a null reference from e.Values["whatever"].
My markup/code is below-

<asp:DetailsView runat="server" ID="basketdetails"
OnItemInserting="DoInsert"
DefaultMode="Insert" AutoGenerateRows="true"
AutoGenerateInsertButton="true"
DataKeyNames="BasketNumber"
HeaderStyle-CssClass="header"
RowStyle-CssClass="rowblue"
AlternatingRowStyle-CssClass="altrowblue">
</asp:DetailsView>

protected void DoInsert(object src, DetailsViewInsertEventArgs e)
{
info.Text = e.Values["CustomerNumber"].ToString() + " " +
e.Values["Total"].ToString() + " " +
e.Values["DateTimeBasketFinished"].ToString() + " " +
e.Values["Notes"].ToString() + ".";
}

All the key values (customernumber, total, datetimebasketfinished, notes)
exist in the data source for the detailsview. e.Values.Count equals zero.
I'd appreciate any help on why the Values are not being populated- perhaps
if someone can post some working code which I can emulate.

Thanks a lot!
Justin Dutoit
 
P

Paul Shapiro

My experience (limited) was that you can only retrieve values for data
actually entered by the user. Set a breakpoint on that line of code and
examine the attributes of the event argument e. You can also check that
e.Exception == null && e.AffectedRows >= 1.
 

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,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top