DetailsView ItemUpdating woes...

  • Thread starter Timothy H. Schilbach
  • Start date
T

Timothy H. Schilbach

Hi Everyone,

I am having a massive issue trying to get custom data into my DV. What I
want to do is sooo simple:

1. I have a single DV on a page
2. I created my own template (see below)
3. I created the DetailsViewDataBinging sub which populates the field using
a datatable
4. I created a ModeChanging Event handler to allow me to change the mode
into EDIT mode
5. I created a ItemUpdating mode to handle the item update.

No matter what I do or what I put in, the e.NewValues or e.OldValue
contain NOTHING... Whan I do a count I see 0 everytime. Non of my fields are
Template fields and they are all databound. Everything works with any
issues, just no data is ever returned.

I hope these shed some light:

DETAILSVIEW1
#################################################################
<asp:DetailsView ID="DetailsView1" runat="server" Width="125px"
AutoGenerateRows="False">

<Fields>

<asp:BoundField DataField="FirstName" HeaderText="First Name:" />

<asp:BoundField DataField="LastName" HeaderText="Last Name:" />

<asp:BoundField DataField="DisplayName" HeaderText="Display Name:" />

<asp:BoundField DataField="Description" HeaderText="Description:" />

<asp:BoundField DataField="PrimaryEmail" HeaderText="Primary Email:"
ReadOnly="True" />

<asp:CommandField ShowEditButton="True" ShowDeleteButton="True" />

</Fields>

</asp:DetailsView>


Protected Sub DetailsView1_ModeChanging(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DetailsViewModeEventArgs) Handles
DetailsView1.ModeChanging

'# When the form mode changes we handle how the form loads and what it looks
like here

Select Case e.NewMode

'Put into edit mode and databind

Case DetailsViewMode.Edit

DetailsView1.ChangeMode(DetailsViewMode.Edit)

'BindDetailsView()

'Put into insert mode

Case DetailsViewMode.Insert

'put into read only mode and databind

Case DetailsViewMode.ReadOnly

DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)

BindDetailsView()

End Select

End Sub

Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles
DetailsView1.ItemUpdating
Response.Write(e.NewValues.Count)

End Sub

What Else am I missing here? This is driving me batty as I cannotdo anything
with my data. All I want to do is intercept the NewValues and put them in my
custom data solution.

-Timothy
 
T

Timothy H. Schilbach

UPDATE:

Ok I dont know why this is, but maybe someone can explain it to me.

My custom data routine that I was using to bind data to my DetailsView was
comming from the active directory. I had created all of the databindings and
everything was working very well. But I could not delete or update any data
as it would tell me there were no fields upon the post back in the
ItemDeleting or ItemUpdating event handlers.

As an experiment I have created an ODS (ObjectDataSource) that has custome
select and custom UPdate routines. I create a USER and EMAILUSER class and
populated them with their corresponding attributes. I was then able to go
back to my test page and drop an ODS connector on there and attach to the
custom select and update routines. I bound that to the DetailsView and low
and behold it works! It now returns the correct number of fields.

Why is it when I use my own DataBinding routines (which bind to the data
just fine) in a code behind page that I have issues when it comes to the
ItemDelting or ItemUpdating routines?

I hate the idea with beign stuck with an ODS as its less efficient now I
have to make 2 calls to my active directory to accomplish the same thing I
was able to do with a single call and some rather complex logic (like adding
and subtracting email address aliases to exchange). While an ODS may be nice
for those afraid of code, I prefer to do my complex operations the old
school way in the code behind page.

Can anyone shed any light on this?

-Timothy
 

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,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top